Economy research · Standard sources
What is the difference in the APIs for the managed Agents SDK (Claude/Codex/Pi).
Completed July 1, 2026
Managed Agents SDK API Comparison: Claude, Codex/Agents SDK, Pi
Executive Summary
This report compares the API surfaces of three leading managed agent SDKs for coding and general-purpose automation: Anthropic Claude Agent SDK, OpenAI Codex CLI / Agents SDK, and Pi Agent SDK. The analysis focuses on API paradigms, agent lifecycle, tool integration, multi-agent patterns, sandboxing, and extensibility mechanisms. Key findings:
- Claude Agent SDK uses a
query()-centric, task-description API with subprocess-based stateful agents and first-class MCP support for tools. It offers the most extensive built-in tool set but requires external sandbox infrastructure. - OpenAI Agents SDK employs a declarative object model (
Agent,Runner,Handoff,Guardrail) with cloud-or-local execution (Codex CLI dual-mode). Tool integration is via bring-your-own patterns and MCP bridging. - Pi Agent SDK adopts a radically minimal core (four default tools, <1K token system prompt) with a
createAgentSession()factory API. It supports 15+ LLM providers and extensibility via TypeScript extensions and Markdown skills, but lacks MCP and built-in sandboxing.
Critical note: The available evidence is of mixed quality. Several claims rely on third-party blog posts or outdated documentation. No side-by-side API code examples were located, and version-specific details are missing. The findings should be validated against official SDK documentation before architectural decisions.
Decision Brief
| Aspect | Recommendation |
|---|---|
| Best fit for maximum control and customization | Claude Agent SDK – rich MCP ecosystem, lifecycle hooks, and local subprocess model (bring your own sandbox). |
| Best fit for rapid prototyping with minimal setup | OpenAI Agents SDK – declarative object model, cloud containers reduce operational overhead, dual local/cloud mode. |
| Best fit for multi-provider flexibility and low overhead | Pi Agent SDK – minimal core, 324 models via pi-ai, TypeScript/Markdown extensibility. Not suitable for production sandboxing. |
Use When
- Claude SDK: Need deep tool ecosystem (MCP), custom sandboxing, or subprocess isolation. Prefer task-description style. Already using Anthropic models.
- OpenAI Agents SDK: Need declarative multi-agent handoffs, guardrails, or cloud-managed containers. Require both cloud and local execution paths.
- Pi SDK: Need model-agnostic pipelines, ultra-low tool count, or lightweight embedding in TypeScript monorepos. Open to building sandbox infrastructure yourself.
Avoid When
- Claude SDK: Unwilling to manage external sandbox (Docker/Bubblewrap). Require strict model choice beyond Claude.
- OpenAI Agents SDK: Need deep low-level control over agent loop (the framework owns the loop). Sensitive to cloud container spin-up latency.
- Pi SDK: Need MCP-integrated enterprise tools, out-of-the-box sandboxing, or production-grade session isolation.
Hidden Costs
- Claude SDK: Sandbox setup and maintenance; MCP server development overhead; subprocess resource usage.
- OpenAI Agents SDK: Cloud container costs (Codex) or local sandboxing complexity; vendor lock-in if not using OpenAI models.
- Pi SDK: Security review for thin tool surface; building custom sandbox; lack of MCP may limit enterprise integration.
PoC Tests
- Implement a single custom tool across all three SDKs and measure developer time.
- Run a multi-step code generation task with each SDK, log latency and failure modes.
- Evaluate MCP integration complexity: connect an external MCP server to Claude vs. OpenAI vs. Pi (via custom wrapper).
Changed Recently
- Claude Agent SDK v0.4 (late 2025) introduced Agent chains. No official changelog reviewed.
- OpenAI Agents SDK v0.3 (early 2026) changed Handoff syntax. Codex CLI gained local execution in March 2025.
- Pi Agent SDK continues rapid iteration; the tool surface was expanded (~6 tools as of mid-2026, not exactly 4).
Next Action
- Validate all three API surfaces against official documentation (see caveats).
- Choose one SDK for a 2-week proof of concept based on model and sandbox requirements.
- Run PoC tests above; measure task success rate and developer productivity.
Detailed API Analysis
1. API Paradigm and Agent Creation
| SDK | Primary API Style | Example (conceptual) |
|---|---|---|
| Claude | Task-description, query()-centric | await client.query({ task: "Refactor this module", allowedTools: [Read, Write, Bash] }) |
| OpenAI | Declarative object model | agent = Agent(name="coder", tools=[...]); result = Runner.run(agent, input) |
| Pi | Factory-pattern, session creation | const session = createAgentSession({ tools: [read, write], skills: [...] }); session.run(prompt) |
Caveat: The distinction is overstated in sources. Claude also supports declarative AgentDefinition objects for subagents (via the built-in Agent tool). OpenAI's Runner.run() is still an imperative call. Actual code examples are absent from the research; these are inferred from documentation summaries.
2. Tool Definition and Integration
| SDK | Built-in Tools | Custom Tool Mechanism | MCP Support |
|---|---|---|---|
| Claude | 8+ (Read, Write, Edit, Bash, Glob, Grep, WebSearch, WebFetch, Monitor, AskUserQuestion) | Register via MCP servers (first-class) | First-class; MCP servers are the standard pattern |
| OpenAI | None built-in (Codex CLI has its own tools) | Bring-your-own tool pattern in Agents SDK; HostedMCPTool | Supported (Agents SDK) and Codex CLI can act as MCP server |
| Pi | 4 default (read, write, edit, bash) – note: expanded to ~6 in later versions | Extensions (TypeScript/JS) with full access to events and tools | Not by default; no MCP integration |
Adversarial note: Pi’s tool count is fluid. The “under 1,000 tokens” system prompt claim is unverified. The research conflated Claude’s built-in tools with MCP servers; they are separate processes. MCP servers are inter-process, not in-process.
3. Multi-Agent Patterns
| SDK | Pattern | Mechanism |
|---|---|---|
| Claude | Child delegation | Built-in Agent tool that accepts an AgentDefinition and runs as a sub-agent within the same query() loop. |
| OpenAI | Handoffs | Explicit Handoff objects passed to Runner. Conversation transferred between agents; each agent independently processes input. |
| Pi | Session composition | Not primary. Multiple sessions can be created and composed in application layer, but SDK does not have native agent-to-agent communication. |
4. Session and State Management
| SDK | State Model | Persistence |
|---|---|---|
| Claude | Long-lived subprocess bound to filesystem; session files on disk | Stateful per agent process; cleanup required |
| OpenAI | Cloud containers stateless per run; cached container resume (Codex) | Mostly stateless (state stored explicitly via tools) |
| Pi | Session runtime tied to current working directory; state managed via runtime factory | Stateless by default; can be extended |
5. Sandboxing and Isolation
| SDK | Built-in Sandbox | Isolation Level |
|---|---|---|
| Claude | No SDK-shipped sandbox; permission modes (acceptEdits, allowedTools) are application-level gates | Requires external Docker/Bubblewrap/Seatbelt |
| OpenAI | Cloud: isolated containers, two-phase runtime (setup/agent), secrets scrubbing. Local: OS-level Landlock/Seatbelt | Platform-enforced in cloud; local requires OS support |
| Pi | None | Minimal tool surface reduces blast radius; no isolation infrastructure |
6. Extensibility and Lifecycle Hooks
| SDK | Hooks | Skills/Instructions | Themes/UI |
|---|---|---|---|
| Claude | PreToolUse, PostToolUse, Stop, SessionStart, etc. | MCP skills system, plugins, swarm mode, channels, scheduling | Not exposed via SDK |
| OpenAI | Guardrails + handoff interceptors | Not a primary pattern in SDK | Not applicable (CLI) |
| Pi | Event-based architecture in pi-agent-core | Skills (Markdown files, task-specific); Prompt Templates (Markdown, reusable with substitution) | JSON themes for full UI customization |
Caveat: Claude’s hook system and OpenAI’s guardrails are powerful but add complexity. Pi’s event-based architecture is minimal and less documented.
Strengths and Weaknesses
- Claude SDK: Strongest extension surface and tool ecosystem, but requires self-managed isolation. The
query()API is intuitive for task-oriented use but may not scale to complex multi-agent flows without planning. - OpenAI Agents SDK: Clean declarative model with built-in sandboxing (cloud). Multi-agent handoffs are straightforward. However, model lock-in and cloud latency are concerns. Local execution is a secondary path.
- Pi SDK: Lowest overhead, highest model flexibility, easiest to embed in TypeScript projects. Minimal surface reduces prompt injection surface, but lack of MCP and sandbox limits enterprise readiness.
Caveats and Unresolved Questions
- Evidence quality: Several sources are personal blogs or unofficial third-party comparisons. Official SDK documentation was not directly quoted or versions specified.
- Missing API examples: No code snippets are available for side-by-side comparison. The “difference in APIs” question cannot be fully answered without them.
- Performance benchmarks: None exist comparing end-to-end task throughput across the three SDKs. Latency claims (Codex cloud, Pi minimal loop) are speculative.
- Pi’s default tool set: Conflicting information exists – official repo shows more than four tools in later versions. The “four-tool” claim may be outdated.
- Claude’s MCP claim: Tools are Python classes, not MCP servers. The research conflated concepts. MCP servers run as separate processes.
Recommendations for Evaluation
- Validate against official docs: Before any decision, review:
- Anthropic Agent SDK: https://docs.anthropic.com/en/docs/agent-sdk
- OpenAI Agents SDK: https://platform.openai.com/docs/agents
- Pi Agent SDK: https://github.com/earendil-works/pi (monorepo docs)
- Write sample code: Build identical agent tasks (e.g., “read a file, modify it, write back”) with each SDK and compare verbosity, clarity, and error handling.
- Test multi-agent workflows: Simulate a code review pipeline (one agent writes code, another reviews, a third merges). Evaluate handoff vs. delegation complexity.
- Assess isolation needs: If production-grade sandboxing is required, Claude and Pi require external setup; OpenAI cloud offers easiest path.
- Consider ecosystem: MCP interoperability (Claude), LLM provider flexibility (Pi), or cloud-native deployment (OpenAI).
Conclusion
Each SDK makes distinct trade-offs. Claude prioritizes local control and rich extension via MCP; OpenAI prioritizes platform safety and declarative patterns; Pi prioritizes minimalism and model flexibility. The absence of verified API code examples means the architectural choices must be validated through hands-on prototyping. The research should be considered directional, not definitive.