Skip to content
Docs中文GitHub
SKIVA HANDBOOK/ Python SDK

Pydantic AI integration

Refresh discovery before each model request and load Skills through version-checked tools.

On this pageAttach the adapterContinue reading

Complete installation and credentials with the pydantic-ai extra. The example reads the model identifier from SKIVA_MODEL; configure the provider dependencies and API credentials in your host application. This extra does not install every provider. The adapter is tested against Pydantic AI 2.59.0.

Attach the adapter

import asyncio
import os
from pydantic_ai import Agent
from pydantic_ai.capabilities import Caching
from skiva_sdk import SkivaClient, SkillSession
from skiva_sdk.integrations.pydantic_ai import SkivaSkills

async def main():
    agent = Agent(
        os.environ["SKIVA_MODEL"],
        name="skiva-agent",
        deps_type=SkillSession,
        capabilities=[Caching(), SkivaSkills()],
    )
    async with SkivaClient.from_env() as client, agent:
        async with client.bind(consistency="dynamic") as skills:
            result = await agent.run("Review this change", deps=skills)
            print(result.output)

asyncio.run(main())

SkivaSkills provides a named, dynamic discovery instruction part with rewrite semantics, evaluated before every model request. It explicitly refreshes the session at each request, bypassing the normal polling interval. It also registers load_skill and read_skill_file, requiring both expected version fields. Version mismatch/not-found become structured tool results; authorization/network failures abort rather than encourage stale fallback. It does not rewrite historical tool returns or erase derived conclusions. Provider wire placement of instructions depends on Pydantic AI and the provider.

Keep business dependencies with SkivaSkills(get_session=lambda deps: deps.skills). Each run must receive its own session; the capability has no mutable run state. Attach one SkivaSkills capability per Agent (tool names are fixed). This is a dedicated discovery/tool integration, not a replacement for the native Harness Skills workspace backend. Shell/direct filesystem access is not intercepted. Configure application tracing in the host application; the SDK exports no prompts/tokens to an external telemetry service.

An active binding owns both discovery and reads. Bindings follow updates by default. An explicitly pinned binding or reuse-snapshot retry intentionally advertises its fixed catalog. Instructions are not modified while a model request is in flight. Header changes can affect prompt caching.

Continue reading

Python SDK quickstart · Snapshots and update policies · File export and framework integration · SDK reference and testing

GitHub · skiva-python