mirror of
https://github.com/pydantic/pydantic-ai-harness.git
synced 2026-07-21 02:45:34 +00:00
d58ee68f61eb99a6691ed6945f93153f11bd9a37
Pydantic Harness
Composable, reusable capabilities for Pydantic AI agents.
What is it?
Pydantic Harness provides a library of capabilities -- self-contained bundles of system prompts, tools, and lifecycle hooks -- that you can attach to any Pydantic AI agent to give it new powers without writing boilerplate.
Each capability is an AbstractCapability subclass that plugs into the agent loop via Pydantic AI's capabilities API.
Installation
pip install pydantic-harness
Requires Python 3.10+ and pydantic-ai-slim>=1.76.0.
Quick start
from pydantic_ai import Agent
from pydantic_harness import Memory, Skills, Compaction
agent = Agent(
'openai:gpt-4o',
capabilities=[Memory(), Skills(), Compaction()],
)
result = agent.run_sync('Remember that my favourite colour is blue.')
Available capabilities
| Capability | Description |
|---|---|
| AdaptiveReasoning | Dynamically adjust reasoning effort based on task complexity |
| Approval | Require human approval before executing sensitive operations |
| Compaction | Compress conversation history to stay within context limits |
| FileSystem | Read, write, and navigate the local filesystem |
| Guardrails | Validate inputs/outputs and enforce cost and tool constraints |
| KnowsCurrentTime | Inject the current date and time into the system prompt |
| Memory | Persistent key-value memory across agent sessions |
| Planning | Break complex tasks into plans before execution |
| RepoContextInjection | Inject repository structure and context into the system prompt |
| SecretMasking | Detect and redact secrets in agent inputs and outputs |
| SessionPersistence | Save and restore full conversation sessions |
| Shell | Execute shell commands with safety controls |
| Skills | Progressive tool loading via search and activate |
| SlidingWindow | Keep conversation history within a sliding token window |
| StuckLoopDetection | Detect and break out of repetitive agent loops |
| SubAgent | Delegate subtasks to specialised child agents |
| SystemReminders | Inject periodic reminders into the conversation |
| ToolErrorRecovery | Automatically retry or recover from tool execution errors |
| ToolOrphanRepair | Repair orphaned tool calls in conversation history |
| ToolOutputManagement | Control and format tool output for the model |
Documentation
Development
make install # install dependencies
make lint # ruff format check + lint
make typecheck # pyright strict
make test # pytest
make testcov # pytest with coverage
License
MIT
Languages
Python
99.9%