Anthropic's Claude Agent SDK Ships a Self-Running Agent Loop at 7,300 Stars
Anthropic's Claude Agent SDK gives Python developers a full agentic runtime with built-in tools, hooks, subagents, and in-process MCP servers — no framework assembly required.
PRO- Official Python SDK for Claude agents: Anthropic's claude-agent-sdk provides a full agentic runtime with built-in tools, hooks, and subagents — install with
pip install claude-agent-sdk. - Two API surfaces:
query()for stateless one-shot tasks andClaudeSDKClientfor stateful multi-turn conversations with interrupt support. - In-process MCP servers: Custom Python functions can be registered as tools Claude calls directly, eliminating subprocess overhead compared to external MCP servers.
- Hooks for lifecycle control: Python callbacks fire at PreToolUse, PostToolUse, UserPromptSubmit, Stop, and more — enabling logging, blocking, and behavior modification without touching the agent loop.
- Subagents and session forking: Spawn parallel child agents with isolated context windows; resume or fork sessions by ID for branching workflows.
- Free SDK, pay-per-token usage: The SDK is MIT-licensed; costs are purely Anthropic API token usage, with built-in per-session cost tracking in every ResultMessage.
Most agent frameworks hand you a box of parts and ask you to wire them together. Anthropic's Claude Agent SDK takes the opposite approach: give it a prompt and some options, and a fully operational agent loop starts running. The SDK, which crossed 7,300 GitHub stars, is now the official Python interface for building production agents on top of Claude , and it's considerably more opinionated than anything else in the space.
From CLI to programmable runtime
The roots of the SDK trace back to Claude Code, Anthropic's agentic command-line tool that launched as a preview and reached general availability alongside Claude 4. As Claude Code matured, Anthropic began exposing its internal infrastructure as a programmable SDK. The stable 1.0 release followed on September 29, 2025, at which point Anthropic renamed the package from claude-code-sdk to claude-agent-sdk for Python and from @anthropic-ai/claude-code to @anthropic-ai/claude-agent-sdk for TypeScript.
According to Anthropic's guidance, the Claude Code SDK evolved into the broader Claude Agent SDK to support general-purpose agents beyond coding. The design philosophy is explicit: rather than reinventing tool calling on top of a chat API, give the model access to a real computer with real tools and let the agent loop handle the rest.
The agent loop, explained
The SDK manages a four-phase cycle autonomously , gather context, take action, verify work, and iterate , without requiring the developer to implement any of the plumbing. Unlike calling the Anthropic Messages API directly, where you have to manually handle tool execution, parse results, and manage multi-turn state, the SDK owns all of that. Your job is to define the prompt, the tools, and the permissions.
Two API surfaces cover most use cases:
query(), an async generator for one-shot tasks. Each call starts a fresh session with no memory of previous interactions.ClaudeSDKClient, a stateful client that maintains conversation context across multiple exchanges, supports interrupts, and enables custom tools and hooks.
Here's the minimal version of each:
import anyio
from claude_agent_sdk import query
async def main():
async for message in query(prompt="Summarize the README"):
print(message)
anyio.run(main)from claude_agent_sdk import ClaudeSDKClient
import asyncio
async def main():
async with ClaudeSDKClient() as client:
await client.query("Read auth.py")
async for msg in client.receive_response():
print(msg)
# Claude still knows about auth.py here
await client.query("Find all callers of that module")
async for msg in client.receive_response():
print(msg)
asyncio.run(main())This story is for Pro members
You've reached the end of the free preview. Upgrade to AlphaSignal Pro to read the full article - and everything else behind the paywall.