provrun.backends.pydantic_ai

A PydanticAI agent with a filesystem sandbox, in this process.

The agent sees three folders:

/input     the staged inputs, read-only
/output    what the run hands back, writable
/scratch   working space, writable, not part of the bundle

provrun, not the agent, writes the evidence. One PydanticAI capability, evidence_capability, sees every step of the run:

The backend itself has text output and no provider tools, so it never makes the last two; they matter to other callers of the capability.

After the run, the whole message history is imported as one trace_imported event with confidence parsed.

evidence_capability

source

evidence_capability(ctx: RunContext) -> AbstractCapability

Make the PydanticAI capability that writes provrun’s evidence for one run.

Code other than the backend can pass it to its own agent, streamed or not.

Parameter Type Default Description
ctx RunContext required The run whose recorder takes the evidence: model_called, tool_called and the rest the module lists
returns AbstractCapability A capability to pass in an agent’s capabilities; it needs provrun[pydantic-ai]

class PydanticAIBackend

source

PydanticAIBackend(model: Any = None, registry: ToolRegistry | None = None)

A PydanticAI agent with a filesystem sandbox over the run’s folders.

The sandbox mounts the input, output and scratch folders. It needs provrun[pydantic-ai].

Parameter Type Default Description
model Any None A PydanticAI Model to use instead of agent.model, for tests; None infers it from agent.model
registry ToolRegistry | None None Where the agent’s tools are found by name; None is a ToolRegistry of the entry points

PydanticAIBackend.execute

source

async PydanticAIBackend.execute(ctx: RunContext, agent: AgentSpec, run: RunSpec) -> RunResult

Run the agent in the sandbox, and import its message history as trace_imported.

It writes the output to response.txt in the output folder unless the agent wrote that file. Raises ValueError for a tool that the registry lacks or that is not in_process.

Parameter Type Default Description
ctx RunContext required The run; its recorder takes the evidence the module lists
agent AgentSpec required The agent to run; its tools are found in the registry
run RunSpec required The staged inputs and the run’s folders, mounted at /input, /output and /scratch
returns RunResult The agent’s output as text, and its token and request counts