Gortex vs Graphify: Code Exploration Token BenchmarkRead Guide: Gortex vs Graphify: Code Exploration Token Benchmark
hafuture Home

Pydantic AI Pax Coding Agent & Harness Beta Guide

Hands-on guide to Pydantic AI Pax (pydantic-ai-pax) & Harness beta (Nov 25, 2026): uvx launch, --agent custom harnesses, Coder() embedding & cost benchmarks.

Hafuture Engineering Team
Pydantic AIPaxAI Coding AgentAgent HarnessPythonMCPuvxDeveloper Tools
Pydantic AI Pax terminal coding agent and Harness beta guide cover image: uvx instant launch, --agent custom harness, reusable Coder() module, and Harness-Bench cost efficiency

Table of Contents


1. Why Pydantic AI Pax & Harness Stand Out Among Terminal Agents

Developers adopting terminal coding agents have faced an awkward split: turnkey black-box CLIs like Claude Code or Codex CLI feel polished out of the box but lock down their internal tool loops, while building a custom coding agent inside a Python backend meant hand-rolling file editors, shell wrappers, context pruning, and sub-agents from scratch.

Pydantic AI Pax and the Pydantic AI Harness beta unify both worlds. The interactive terminal agent (pydantic-ai-pax) runs on the exact same Coder() capability and 100+ reusable blocks (pydantic-ai-harness) that you can embed directly into production Python applications.

In Pydantic's Harness-Bench SWE81 evaluation (81 real-world software engineering implementation and repair tasks), Pax narrowly led average scores across multiple models in single-run benchmarks—and demonstrated how strongly the harness shapes token cost ("Harness Tax"). On GPT-6.2 Sol, Pax ran at less than half the cost of Codex, while roughly matching Claude Code in both score and cost on Claude Opus 5.5.

Three-layer modular architecture of Pydantic AI Pax plugin TUI and Pydantic AI Harness 100+ capabilities, showing one-line LocalWorkspace to Modal/E2B cloud sandbox swap and a comparison against Claude Code, Codex, and OpenCode
Pydantic AI Pax & Harness modular 3-layer stack (left) and comparison against major terminal coding agents (right)

2. Architecture Deep Dive: Plugins, Coder(), Code Mode & Sandboxes

Pax follows an "Everything is a Plugin" philosophy on Python 3.11+: even the default coding agent, sandboxes, MCP connectors, and Logfire tracing behave as toggleable, composable modules.

Layer / FeatureCore Building BlocksPractical Advantage
Terminal UI (Pax)pydantic-ai-pax TUI, mid-session provider switching, session recoveryImports existing conversation history from Claude Code & Codex; toggle plugins live
Reusable Coding Bundlepydantic_ai_harness.coder.Coder()Path-restricted file ops, ripgrep(rg) search, shell execution, auto-reads CLAUDE.md & AGENTS.md, sub-agent delegation
Code Mode ([code-mode])Single run_code execution stepReplaces serial tool round-trips with Python blocks (loops, conditionals, asyncio.gather parallelism)
Workspaces & SandboxesLocalWorkspace('.') ↔ ModalSandbox() etc.Swap local execution for Modal, E2B, Render, Sprites, Daytona, OpenSandbox, or boxd without touching agent logic
Observability & Custom AgentsMCP plugins, Logfire tracing, --agent flagWrite custom plugins in a few lines of Python or attach any custom Pydantic AI Agent directly into Pax

3. Claude Code, Codex & OpenCode vs. Pax Selector

Choose the Right Terminal Coding Agent for Your Stack
Pydantic AI Pax & Harness

Open-source Python plugin TUI + embeddable 100+ capability SDK

“uvx launch · --agent · Sandbox swap”

Strengths
Shared Coder() across TUI and apps, 1-line Modal/E2B sandbox swap, strong Harness-Bench cost efficiency
Extensibility
Type-safe Python plugins, MCP, Logfire tracing, and bring-your-own --agent support
Caveat
Harness is pre-1.0 beta; watch out for macOS built-in /bin/pax name collision
Best For
Python/AI engineers building custom coding agents, internal dev tools, or sandboxed bots
Anthropic Claude Code

Turnkey Anthropic coding agent integrated with Claude Ship

“Zero assembly · /ship · Official polish”

Strengths
Top-tier out-of-the-box coding, PR automation (/ship), and Code Mode with minimal setup
Extensibility
MCP, Skills, Hooks, and CLAUDE.md—though the core harness loop stays closed
Caveat
Anthropic-centric ecosystem; not designed as an embeddable Python SDK
Best For
Teams seeking maximum immediate velocity with zero harness maintenance
OpenCode / Codex CLI

Multi-provider open TUI or official OpenAI terminal agent

“Fast model swap · Low Python overhead”

Strengths
Quick installation across non-Python stacks for interactive terminal coding
Extensibility
Config- and MCP-driven rather than programmable Python capability composition
Caveat
Token cost can vary sharply by harness/model pairing (Harness Tax)
Best For
Non-Python developers wanting a straightforward daily terminal assistant

4. Hands-On Commands: uvx Launch, --agent & Modal Sandbox Embedding

The tabs below reflect the verified CLI and Python patterns from Pydantic's official beta release notes (pydantic.dev/articles/pax-harness-beta).

bash
# Run immediately in an ephemeral environment without permanent install
uvx pydantic-ai-pax

# Install globally with bytecode compilation for faster startup
uv tool install --compile-bytecode pydantic-ai-pax

# Mount your own custom Pydantic AI Agent inside Pax TUI
uvx pydantic-ai-pax --agent my_package.agent:my_custom_agent -m anthropic:claude-sonnet-4-6
macOS includes a built-in /bin/pax archiving utility; prefer uvx pydantic-ai-pax or verify ~/.local/bin precedes /bin in PATH.

5. 4-Step Adoption Plan & Practical Gotchas (Including macOS /bin/pax)

  1. 1
    Step 1 — Pilot Zero-Install via uvx & Import Existing Sessionsuvx pydantic-ai-pax

    Test Pax without polluting your global Python environment. Verify automatic CLAUDE.md/AGENTS.md loading, mid-conversation model switching, and importing history from Claude Code or Codex.

  2. 2
    Step 2 — Measure Harness Tax with Code Mode & Logfire TracingCode Mode (run_code) + Logfire Plugin + MCP

    Enable Code Mode to collapse multi-file tool round-trips into batched Python execution, and turn on the Logfire tracing plugin to inspect per-turn token spend and latency.

  3. 3
    Step 3 — Standardize Team Workflows via --agent Modulesuvx pydantic-ai-pax --agent company_agent.cli:agent

    Version-control your team's custom Pydantic AI Agent (internal tools, approval policies, MCP servers) in Git so every engineer launches the exact same harness inside Pax.

  4. 4
    Step 4 — Move Unattended Runs to Cloud SandboxesLocalWorkspace('.') -> ModalSandbox() / E2B / Daytona

    Before running autonomous bug-fix or CI workflows unattended, swap LocalWorkspace('.') for ModalSandbox() or E2B so untrusted shell commands never touch host credentials.

Practical Gotchas & Operations Explorer

Pydantic AI Pax & Harness Gotcha Explorer4items
  • Running `pax` on macOS launches an old archive utility instead of Pydantic AI PaxmacOS Trap· CLI & macOS

    If /bin appears earlier in PATH or the shell hash table isn't refreshed, typing `pax` invokes macOS's system binary instead of Pydantic's CLI.

    Key Caveat:macOS ships with a built-in POSIX archive tool at /bin/paxRecommended Fix:Run `uvx pydantic-ai-pax` directly or ensure ~/.local/bin precedes /bin in PATH and open a fresh terminal after `uv tool install`.
  • Why did default coding tools disappear when I passed `--agent my_module:agent`?--agent Scope· CLI & macOS

    Passing `--agent` gives you full control over instructions, models, and tools without hidden defaults colliding with your custom workflow.

    Key Caveat:Expected behavior — `--agent` bypasses built-in default plugins to load your exact AgentRecommended Fix:Explicitly include `Coder()` and `LocalWorkspace('.')` in your custom agent's `capabilities=[...]` list if you still want built-in coding tools.
  • Why can two CLI harnesses using the exact same model differ by >2x in token cost?Harness Tax· Cost & Code Mode

    On Harness-Bench SWE81 with GPT-6.2 Sol, Pax ran at under half the cost of Codex thanks to modular context handling and Code Mode (`run_code`).

    Key Caveat:System prompts, context pruning, and tool round-trip loops multiply token usageRecommended Fix:Enable Logfire tracing during pilots to compare cost-per-solved-task rather than looking only at pass rates.
  • Is Pydantic AI Harness beta safe to embed in production pipelines today?Beta Caution· Sandboxes & Beta

    Because `pydantic-ai-harness` is in beta ahead of 1.0, minor capability API adjustments can still land between releases.

    Key Caveat:Yes for controlled rollouts—provided you pin versions and isolate execution in sandboxesRecommended Fix:Pin dependencies via `uv.lock` and swap `LocalWorkspace('.')` to `ModalSandbox()` or E2B for unattended production runs.

6. Frequently Asked Questions (FAQ)

Q1. Is Pydantic AI Pax free to use?
Yes. Both pydantic-ai-pax and pydantic-ai-harness are open-source Python packages free to run; you only pay your chosen LLM provider's API usage (Anthropic, OpenAI, Google, etc.).
Q2. Can I use Pax on repositories already configured for Claude Code or Codex?
Yes. The Coder() capability automatically detects and reads CLAUDE.md and AGENTS.md instructions, and Pax supports importing conversation history from Claude Code and Codex.
Q3. How does Code Mode ([code-mode]) reduce latency and token cost?
Instead of making sequential tool-call round-trips for every file read or search, Code Mode wraps tools in a single run_code step where the model writes Python loops or asyncio.gather parallel calls to finish multiple operations in one turn.
Q4. Which cloud sandboxes work with Pydantic AI Harness?
The workspace abstraction supports local execution as well as cloud sandboxes and micro-VMs including Modal, E2B, Render, Sprites, Daytona, OpenSandbox, and boxd.
Q5. How do I avoid the macOS /bin/pax conflict?
Launch Pax via uvx pydantic-ai-pax, or install globally with uv tool install --compile-bytecode pydantic-ai-pax and ensure ~/.local/bin precedes /bin in your shell PATH in a fresh terminal session.

Inspect Structured Agent Outputs & MCP Configs with Hafuture JSON Formatter

Format and validate Pydantic AI structured JSON outputs, MCP manifests, and Logfire trace payloads locally in your browser.

Open JSON Formatter