Pydantic AI Harness is the official capability and harness library for Pydantic AI. A Pydantic AI agent already carries a light harness — the typed agent loop, a choice of model, your tools, structured output — which covers simple agents. This package adds what an agent needs for long-running work: a workspace to act in, a plan it keeps current, memory that carries across sessions, sub-agents to hand work to, context management that holds up over hours, and durable execution that survives a restart.
Everything is one primitive, a capability: a self-contained unit of agent behaviour added to an agent's capabilities list. Complete agents are themselves capabilities combined, so Coder is not a framework inside the framework but a combined capability bundling a workspace-rooted filesystem, an allowlisted shell with LLM API keys stripped from its environment, repository orientation from AGENTS.md or CLAUDE.md, planning, a read-only explorer sub-agent, and context controls. Start from a whole agent and take it apart, or compose from the blocks; constructor arguments thread through to the underlying capabilities.
The capabilities span several areas. Execution environments cover a path-traversal-safe filesystem, a guarded shell, and an isolated cloud sandbox. Tools reach MCP servers, image generation, linked SaaS accounts, an emulated AWS environment, and a local code review. Web and research cover native or local search and fetch, X search, Exa and You.com, an autonomous browser agent, and direct Chromium control. Reasoning covers extended thinking, model-owned plans, sub-agents, script-driven fan-out with hard call budgets, and consulting a stronger model mid-run.
Context management is treated as its own group: a code mode where the model writes one Python script calling many tools inside a sandbox so intermediate results never enter the context window, on-demand tool definitions, provider-native and model-agnostic compaction strategies, truncation or spill-to-file for oversized tool returns, and detection of prompt-cache prefix collapses from the provider's own numbers. Knowledge and memory add a namespaced notebook with in-memory, file, and Postgres stores, BM25 search over stored history including turns compaction dropped, on-demand SKILL.md procedures, and documentation lookup.
Any provider's model works by swapping the model string, and the agent runs anywhere a Pydantic AI agent runs: a terminal chat, the browser, the Agent Client Protocol for editors, or the AG-UI and Vercel AI adapters. Requires Python 3.10+.
Features
- Capabilities as the unit: every behaviour is a self-contained capability that composes with the others and with your own
- Ready-made harnesses: Coder and Researcher are combined capabilities that come apart into their blocks
- Execution environments: safe filesystem access, an allowlisted credential-stripping shell, and an isolated cloud sandbox
- Web and research: native or local search and fetch, Exa and You.com, browser automation, and direct Chromium control
- Planning and delegation: model-owned plans, sub-agents, script-orchestrated fan-out with call budgets, and mid-run escalation
- Context management: code mode, on-demand tool definitions, compaction, tool-output limits, and cache-bust detection
- Memory and knowledge: a namespaced notebook, BM25 conversation search, on-demand skills, and repository orientation
- Control and safety: guardrails, prompt-injection classification, spend limits, and human tool approval
- Durable runs: Temporal, DBOS, and Prefect execution plus save, restore, resume, and fork
- Observability: OpenTelemetry GenAI spans for every model and tool call, with token and cost tracking
- Self-extension: an agent can write and persist new capabilities that load on the next run
- Interfaces: terminal chat, web chat UI, Agent Client Protocol, frontend adapters, and realtime voice
Integrates with
Browser Use
Python library that lets an LLM agent operate a web browser — opening pages, clicking, typing, and filling forms from a task description
Exa
Embeddings-based web Search, Contents, Answer and Agent APIs for retrieval inside agents; the separate Exa MCP server is already catalogued.
Logfire
OpenTelemetry-based observability platform with Python-centric insights, SQL querying, and Pydantic integration
Playwright
Drives Chromium, Firefox, and WebKit through one API for e2e tests, scripts, and AI-agent automation via MCP or CLI