pydantic/pydantic-ai-harness
Batteries for your Pydantic AI agent.
TL;DR
Pydantic AI Harness is a library of plug‑in‑style capabilities that turn a Pydantic AI agent into a fully‑featured autonomous worker. It bundles tools for file‑system access, shell commands, web search, memory, planning, sub‑agents, safety guards, durable execution, and many SaaS integrations. You compose the pieces you need (e.g., the ready‑made Coder harness) and drop them into an Agent’s capabilities list.
What it does
- Provides a catalog of 50+ capabilities – each a self‑contained unit (tool, memory store, guard, etc.) that can be added to any
pydantic_ai.Agent. - Ready‑made harnesses such as:
- Coder – file editing, persistent shell, delegation, and autonomous coding workflow.
- Researcher – web‑search, page fetch, sub‑researcher delegation.
- Execution environment helpers: safe file‑system access, sandboxed shells, optional Modal cloud sandbox.
- Tool integrations for GitHub, Linear, Notion, Google Workspace, Slack, and many other SaaS services via MCP or hosted APIs.
- Web & research utilities: DuckDuckGo fallback search, Exa, You.com, Playwright browser control, etc.
- Planning & orchestration – model‑owned task plans, sub‑agents, dynamic workflows, background concurrent tools.
- Context management – compaction, tool‑output limits, code‑mode execution, sliding‑window trimming.
- Memory & knowledge – persistent notebooks, conversation search, on‑demand skill loading, repo‑context hints.
- Safety & control – guardrails, prompt‑injection defense, spend limits, human‑in‑the‑loop tool approval, trajectory judging.
- Self‑extension – agents can generate and persist new capabilities during a run.
- Durable execution – runs survive restarts via Temporal, DBOS, Prefect, Airflow, etc.; AWS Lambda checkpointing; step persistence back‑ends.
- Observability – OpenTelemetry spans, Logfire integration, managed prompts.
Who it’s for
- Developers building autonomous agents that need to run for long periods (e.g., fixing a codebase, researching a topic) and require robust tooling, memory, and safety.
- Teams that want to compose custom AI‑agent stacks without writing low‑level plumbing; they simply import the needed capabilities.
- Ops / production teams that need durable, observable, and cost‑controlled runs.
How to get started
# using uv (recommended)
uv add "pydantic-ai-harness[anthropic]"
# or with pip
pip install "pydantic-ai-harness[anthropic]"
from pydantic_ai import Agent
from pydantic_ai_harness import Coder
agent = Agent('anthropic:claude-fable-5', capabilities=[Coder()])
result = agent.run_sync('Fix the bug in tests/test_parser.py')
print(result.output)
For a full CLI experience:
uvx --with "pydantic-ai-harness[coder]" clai -a pydantic_ai_harness.coder:coder_agent -m anthropic:claude-fable-5
Add more capabilities as needed, e.g., memory or web search:
from pydantic_ai.capabilities import WebSearch
from pydantic_ai_harness.memory import FileStore
from pydantic_ai_harness import Memory
agent = Agent(
'openai:gpt-5.6-sol',
capabilities=[Coder(), WebSearch(), Memory(FileStore('.agent-memory'))],
)
What’s inside (selected highlights)
| Category | Example Capability | Core idea |
|---|---|---|
| Harnesses | Coder, Researcher |
Pre‑built stacks you can drop in. |
| Filesystem | FileSystem |
Safe read/write/list under a root, optional ripgrep. |
| Shell | Shell |
Execute commands with allow/deny lists, timeouts, persistent state. |
| SaaS integrations | GitHub, Slack, Notion, Linear … |
Direct API‑level access via MCP or hosted servers. |
| Web | WebSearch, Exa, Playwright |
Search the web, fetch pages, drive a real browser. |
| Planning | Planning |
Model‑owned task plan with live reminders. |
| Memory | Memory (FileStore, Postgres, etc.) |
Persistent, searchable notebook across runs. |
| Safety | Guardrails, PromptInjectionDefender, Spend |
Validate inputs/outputs, enforce cost limits, block risky tool results. |
| Durability | Durable execution, Step Persistence, AWS Lambda durability |
Checkpoint runs, survive restarts, integrate with workflow engines. |
| Observability | Instrumentation, Logfire MCP |
OpenTelemetry spans, Logfire tracing. |
Why it matters
Pydantic AI already gives you a typed agent loop and tool‑calling support. Pydantic AI Harness turns that into a production‑ready platform: you can build agents that edit code, browse the web, interact with SaaS tools, remember past work, stay within budgets, and keep running even if the process crashes. All pieces are modular, typed, and documented, letting you start with a ready‑made harness and then peel away or replace individual capabilities to fit your exact use‑case.
Links & resources
- Docs: https://pydantic.dev/docs/ai/harness
- GitHub repo (archived): https://github.com/pydantic/pydantic-ai-harness
- Main Pydantic AI repo: https://github.com/pydantic/pydantic-ai
- PyPI package: https://pypi.org/project/pydantic-ai-harness/
- Slack community: https://logfire.pydantic.dev/docs/join-slack/
All information above is taken directly from the repository’s README; no additional features are inferred.
Related
- Project
- Project
- Project
- Project
- Project