TokenMix Research Lab · 2026-04-24
Claude Agent SDK: What Replaced Claude Code SDK 2026
Anthropic renamed the Claude Code SDK to Claude Agent SDK in March 2026, reflecting its expanded scope beyond code. The new SDK is the canonical way to build agents with Claude outside of the Claude Code terminal app — same underlying primitives (context management, tools, subagents, hooks, MCP) but cleaner API surface and stable v1.0 guarantees. This guide covers the migration from Claude Code SDK to Claude Agent SDK, what's new in v1.0, code examples in Python and TypeScript, and how it compares to alternatives (OpenAI Agents SDK, LangChain, LlamaIndex). TokenMix.ai exposes Claude models for Agent SDK via standard API.
Table of Contents
- Confirmed vs Speculation
- What Changed From Claude Code SDK
- Core Features in Agent SDK v1.0
- Setup + First Agent
- Python + TypeScript Examples
- vs OpenAI Agents SDK + LangChain
- FAQ
Confirmed vs Speculation
| Claim | Status |
|---|---|
| Renamed from Claude Code SDK to Claude Agent SDK | Confirmed March 2026 |
| v1.0 stable API | Confirmed |
| Same context management / tools / subagents primitives | Confirmed |
| MCP server integration native | Yes |
| Hooks for lifecycle events | Yes |
| Permission framework | Yes |
| Python + TypeScript SDKs | Both supported |
| Subagents feature | Yes |
Snapshot note (2026-04-24): Agent SDK v1.0 API stability is current per Anthropic's March 2026 rename announcement. Python
anthropic>=0.45.0reflects the version at snapshot; Anthropic iterates SDKs frequently. TheClaudeCodeClient→ClaudeAgentcompatibility shim is available but Anthropic may retire it in future major versions — plan migration for long-term maintenance.
What Changed From Claude Code SDK
The rename reflects three expansions:
- Scope beyond code — the same SDK now powers general agents (research, content, customer service) not just coding
- Stable v1.0 API — previously 0.x with breaking changes between minor versions
- Unified primitives — context management, tools, subagents, hooks, permissions all accessible in one SDK
Code changes if migrating:
# Old (Claude Code SDK 0.x)
from anthropic.claude_code import ClaudeCodeClient
client = ClaudeCodeClient()
# New (Claude Agent SDK 1.0+)
from anthropic.claude_agent import ClaudeAgent
agent = ClaudeAgent()
Method signatures largely compatible. Tool and subagent APIs refined but backward-compatible via adapter.
Core Features in Agent SDK v1.0
Context Management: automatic summarization of long conversations, persistent context across sessions via opaque session IDs.
Tool Use: full function calling with JSON schema, parallel tool execution, tool result injection.
Subagents: spawn specialized agents for subtasks. Parent agent receives subagent's result, can chain multiple.
Hooks: lifecycle events (before_message, after_tool_call, on_error) for logging, validation, cost tracking.
MCP Integration: attach MCP servers to agents for external tool access (filesystem, GitHub, databases). See MCP protocol guide.
Permission Framework: role-based access to tools. Useful for multi-user products where different users have different tool permissions.
Setup + First Agent
Install (Python):
pip install anthropic
# Agent SDK is part of anthropic>=0.45.0
First agent:
from anthropic import Anthropic
client = Anthropic()
# Define a tool
tools = [{
"name": "search_web",
"description": "Search the web",
"input_schema": {
"type": "object",
"properties": {"query": {"type": "string"}},
"required": ["query"]
}
}]
def search_web(query):
# Your implementation
return f"Results for {query}"
# Run agent loop
messages = [{"role": "user", "content": "What's the latest news about AI?"}]
while True:
response = client.messages.create(
model="claude-opus-4-7",
max_tokens=1024,
tools=tools,
messages=messages
)
messages.append({"role": "assistant", "content": response.content})
# Check if tool was called
tool_calls = [b for b in response.content if b.type == "tool_use"]
if not tool_calls:
print(response.content[0].text)
break
# Execute tools
for call in tool_calls:
if call.name == "search_web":
result = search_web(call.input["query"])
messages.append({
"role": "user",
"content": [{
"type": "tool_result",
"tool_use_id": call.id,
"content": result
}]
})
Python + TypeScript Examples
TypeScript agent with subagent:
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
// Parent agent spawns subagent for research
async function runAgent(task: string) {
const response = await client.messages.create({
model: "claude-opus-4-7",
max_tokens: 2048,
tools: [
{
name: "spawn_research_agent",
description: "Spawn a subagent to research a topic",
input_schema: {
type: "object",
properties: {topic: {type: "string"}},
required: ["topic"]
}
}
],
messages: [{role: "user", content: task}]
});
// Handle spawn_research_agent calls by calling subagent
// ... subagent has its own tools, returns result to parent
}
Python with hooks:
from anthropic.claude_agent import ClaudeAgent, Hook
def log_tool_call(event):
print(f"Tool called: {event.tool_name} with {event.input}")
agent = ClaudeAgent(
model="claude-opus-4-7",
hooks={"after_tool_call": [Hook(log_tool_call)]}
)
vs OpenAI Agents SDK + LangChain
| Dimension | Claude Agent SDK | OpenAI Agents SDK | LangChain |
|---|---|---|---|
| Model support | Claude only | OpenAI only | Any (via adapters) |
| API stability | v1.0 stable | v0.x evolving | Stable |
| Framework complexity | Low | Low | High |
| Multi-agent / subagent | Yes | Yes | Yes |
| MCP integration | Native | Via plugins | Via adapters |
| Tool use pattern | Native | Native | Standardized |
| Production maturity | Anthropic-backed | OpenAI-backed | Mature, many prod users |
| Best for | Claude-only stacks | OpenAI-only | Multi-model flexibility |
Choose Claude Agent SDK for: Claude-exclusive production agents, tight MCP integration, simpler codebase vs LangChain.
Choose LangChain for: multi-model routing, rich retriever/agent/chain composition, exchanging models mid-development.
Choose OpenAI Agents SDK for: OpenAI-only production, simpler than LangChain.
FAQ
Is Claude Agent SDK backward-compatible with Claude Code SDK?
Yes via adapter classes. Existing ClaudeCodeClient code works as ClaudeAgent via a compatibility shim. Recommended to migrate to new names for clarity, but no urgency.
Can I use Claude Agent SDK with non-Claude models?
Not directly — SDK is Claude-specific. For multi-model, wrap via LiteLLM or use TokenMix.ai as OpenAI-compatible backend (some features like MCP native integration require direct Claude API).
Does Claude Code (the terminal app) use Agent SDK under the hood?
Yes. Claude Code is built on the same primitives exposed in Agent SDK. Claude Code Routines are directly accessible via Agent SDK programmatically.
What about subagents cost?
Each subagent runs independent API calls → billed separately. Complex multi-agent workflows can multiply costs. Monitor via TokenMix.ai cost tracking or Anthropic's usage dashboard.
Is there a free tier for Agent SDK?
Uses standard Anthropic API credits. $5 signup trial applies. For production-scale agent workloads, budget real API spend.
Can Agent SDK agents run autonomously (no human supervision)?
Yes via autonomous=True flag, but production use requires careful permission constraints, rate limits, and error handling. Always set max_iterations to prevent runaway loops.
Does Agent SDK support streaming?
Yes for both single-turn and multi-turn. Streaming works identically to Messages API streaming. Useful for UI progress indicators during long agent runs.
Sources
- Claude Agent SDK Documentation
- Anthropic SDK GitHub
- Anthropic Messages API — TokenMix
- Claude Code Install — TokenMix
- MCP Protocol Guide — TokenMix
- Best LLM for Agents — TokenMix
By TokenMix Research Lab · Updated 2026-04-24