Pydantic Ai Harness logo

Pydantic Ai Harness

Organization
pydantic
pydantic-ai-harness

Extend Pydantic AI agents with batteries-included capabilities from pydantic-ai-harness -- Code Mode (collapse many tool calls into one sandboxed Python execution), a filesystem and shell, sub-agents, planning, context compaction, and more. Use when the user mentions pydantic-ai-harness, CodeMode, Monty, code mode, or tool sandboxing, when they want first-party filesystem/shell/sub-agent/planning/compaction capabilities for a Pydantic AI agent, when they want an agent to run agent-written Python, or when a Pydantic AI agent would benefit from orchestrating multiple tool calls in a single sandboxed script.

Overview

Publisherpydantic
Repositorypydantic-ai-harness
Skill namepydantic-ai-harness
Stars
954
Forks
150
Bundled files
1
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • 1 bundled files

    Scripts, templates, and references the model can read while it works. Files are read-only and never executed.

  • Open source

    Published by pydantic on GitHub. Read the source before you install it.

Installation

Install the Pydantic Ai Harness AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/pydantic/pydantic-ai-harness/tree/main/pydantic_ai_harness/.agents/skills/pydantic-ai-harness
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/pydantic/pydantic-ai-harness.git /tmp/pydantic-ai-harness
mkdir -p .claude/skills
cp -r /tmp/pydantic-ai-harness/pydantic_ai_harness/.agents/skills/pydantic-ai-harness .claude/skills/pydantic-ai-harness
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Pydantic Ai Harness in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Pydantic Ai Harness on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Pydantic Ai Harness is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Building with Pydantic AI Harness

Pydantic AI Harness is the official capability library for Pydantic AI. Capabilities that need model or framework support -- and those fundamental to every agent -- live in core pydantic-ai; optional, batteries-included capabilities live here. Both are composed onto an agent through the same capabilities=[...] API.

This skill covers the capabilities shipped by pydantic-ai-harness. For the core framework -- agents, tools, structured output, hooks, and testing -- use the building-pydantic-ai-agents skill instead.

When to Use This Skill

Invoke this skill when:

  • The user mentions pydantic-ai-harness, CodeMode, code mode, or the Monty sandbox
  • An agent makes many sequential tool calls that could collapse into one sandboxed Python execution
  • The user wants the model to write Python that loops, branches, aggregates, or parallelizes tool calls with asyncio.gather
  • The user asks to sandbox or constrain the code an agent runs

Do not use this skill for:

  • Core Pydantic AI usage -- building agents, adding tools, structured output, streaming, or testing (use building-pydantic-ai-agents)
  • Capabilities that ship in core pydantic-ai, such as web search, tool search, and thinking
  • The Pydantic validation library on its own (pydantic/BaseModel without agents)

Supported Capabilities

CodeMode has a full reference below; it is the flagship capability and the one this skill goes deep on. The rest ship today and each has its own README with API and examples.

Each capability lives in its own submodule and is imported from there (from pydantic_ai_harness.<module> import ...). Capabilities are not importable from the top-level pydantic_ai_harness package by design, so each one keeps its own optional dependencies isolated. CodeMode, FileSystem, Shell, and ManagedPrompt also have top-level re-exports (importable directly from pydantic_ai_harness).

APIs are subject to change between releases; breaking changes ship deprecation warnings where practical.

CapabilityModuleDescription
CodeModepydantic_ai_harness.code_mode (also top-level)Wraps eligible tools into a single sandboxed run_code tool so the model orchestrates them in Python -- see Code Mode
FileSystempydantic_ai_harness.filesystem (also top-level)Read, write, edit, and search files under a root directory, with traversal prevention
Shellpydantic_ai_harness.shell (also top-level)Run commands in a subprocess with allowlists, a default denylist, timeouts, and env masking
ManagedPromptpydantic_ai_harness.logfire (also top-level)Back an agent's instructions with a Logfire-managed prompt
SubAgentspydantic_ai_harness.subagentsDelegate subtasks to specialized child agents
DynamicWorkflowpydantic_ai_harness.dynamic_workflowOrchestrate sub-agents from a model-written Python script
Planningpydantic_ai_harness.planningBreak complex tasks into structured plans before execution
compaction family (SlidingWindowCompaction, SummarizingCompaction, ...)pydantic_ai_harness.compactionTrim or summarize conversation history to stay within token limits
ToolOutputLimitspydantic_ai_harness.tool_output_limitsTruncate, summarize, or spill large tool outputs
RepoContextpydantic_ai_harness.repo_contextAuto-load CLAUDE.md/AGENTS.md and repo structure
StepPersistencepydantic_ai_harness.step_persistenceSave, restore, resume, and fork run state
PydanticAIDocspydantic_ai_harness.pydantic_ai_docsOn-demand read_pyai_docs tool for Pydantic AI docs
CapabilityCreationpydantic_ai_harness.capability_creationLet an agent author, validate, and load real capabilities at runtime
media externalizationpydantic_ai_harness.mediaOffload large BinaryContent to content-addressed stores

Still experimental: an ACP server adapter, imported from pydantic_ai_harness.experimental.acp. Importing it emits a HarnessExperimentalWarning.

The full, current list with links and status is in the capability matrix.

Install

bash
uv add pydantic-ai-harness

Each capability declares its own extra. Code Mode needs the Monty sandbox:

bash
uv add "pydantic-ai-harness[codemode]"   # `code-mode` is also accepted as an alias

Requires Python 3.10+ and pydantic-ai-slim>=2.18.0.

Quick Start

A harness capability is added to the agent like any other. Here CodeMode wraps locally registered tools into a single run_code tool that the model drives with Python.

python
from pydantic_ai import Agent

from pydantic_ai_harness import CodeMode

agent = Agent('anthropic:claude-sonnet-4-6', capabilities=[CodeMode()])


@agent.tool_plain
def get_temperature_f(city: str) -> float:
    return {'Paris': 68.0, 'Tokyo': 77.0}[city]


@agent.tool_plain
def convert_temp(fahrenheit: float) -> float:
    return round((fahrenheit - 32) * 5 / 9, 1)

result = agent.run_sync(
    'Compare the weather in Paris and Tokyo, and report both temperatures in Celsius.'
)
print(result.output)
#> Paris is 20.0 C and Tokyo is 25.0 C.

The model writes a single Python script that fetches both temperatures with asyncio.gather and then converts them -- performing four tool calls across two dependent stages in one run_code invocation.

Key Practices

  • Confirm a harness capability is actually needed. If core Pydantic AI tools and capabilities are enough, use the building-pydantic-ai-agents skill instead -- don't reach for the harness by default.
  • Read the reference before writing code. Each capability has its own configuration, constraints, and gotchas -- load the linked reference (e.g. Code Mode) first.
  • Install the capability's extra. Importing CodeMode without pydantic-ai-harness[codemode] raises an ImportError; the Monty sandbox is an optional dependency.

Common Gotchas

  • native=True tools bypass CodeMode. Provider-native MCP servers and web search execute server-side, so run_code never sees them. Use native=False for client-side dispatch that CodeMode can wrap, but do not treat a remote server as trusted or sandboxed; see the Code Mode trust boundary.
  • The Monty sandbox is a Python subset. It has no third-party imports and only a small stdlib allowlist -- read Code Mode before debugging generated code that fails to run.
  • CodeMode needs its extra. Install pydantic-ai-harness[codemode], not the bare package.

Bundled files

The model reads these on demand while the skill is loaded. They are exposed as readable files and are never executed.

Frequently asked questions

What does the Pydantic Ai Harness AI skill do?

Extend Pydantic AI agents with batteries-included capabilities from pydantic-ai-harness -- Code Mode (collapse many tool calls into one sandboxed Python execution), a filesystem and shell, sub-agents, planning, context compaction, and more. Use when the user mentions pydantic-ai-harness, CodeMode, Monty, code mode, or tool sandboxing, when they want first-party filesystem/shell/sub-agent/planning/compaction capabilities for a Pydantic AI agent, when they want an agent to run agent-written Python, or when a Pydantic AI agent would benefit from orchestrating multiple tool calls in a single sa...

Why use Pydantic Ai Harness on TypingMind?

Because you install it once and use it with any model. Pydantic Ai Harness is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Pydantic Ai Harness in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/pydantic/pydantic-ai-harness/tree/main/pydantic_ai_harness/.agents/skills/pydantic-ai-harness. TypingMind reads its SKILL.md and bundles its files and installs it as a skill you can enable per chat.

Which AI models can use Pydantic Ai Harness?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Pydantic Ai Harness?

As many as you like. As long as a model supports skills, you can use Pydantic Ai Harness with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Pydantic Ai Harness AI skill free?

Yes. It is published on GitHub by pydantic under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇