CLI ToolsApr 8, 2026·2 min read

Anthropic Agent SDK — Build Production AI Agents

Official Anthropic SDK for building AI agents with tool use, memory, and orchestration. Production-grade agent framework with Claude as the backbone for autonomous tasks.

TL;DR
Official Anthropic SDK for building production AI agents with tool use, memory, orchestration, and Claude as the backbone.
§01

What it is

The Anthropic Agent SDK is the official framework for building AI agents powered by Claude. It provides structured tool use, memory management, multi-step orchestration, and guardrails for production deployments. The SDK handles the agent loop (observe, think, act, repeat) with built-in error recovery, token management, and conversation persistence.

The SDK targets developers building autonomous AI applications: customer support agents, research assistants, code generation pipelines, and workflow automation. It provides the production scaffolding that turns a single LLM call into a reliable agent system.

§02

How it saves time or tokens

The SDK manages the agent loop internally, handling retries, tool call parsing, and conversation state. Without it, you write custom code for each of these concerns. Built-in token management prevents context window overflow by summarizing or truncating conversation history automatically. Error recovery means failed tool calls are retried with context rather than crashing the entire agent session.

§03

How to use

  1. Install the SDK:
pip install claude-agent-sdk
  1. Define tools and create an agent:
from claude_agent_sdk import Agent, tool

@tool
def search_web(query: str) -> str:
    'Search the web for information.'
    return do_search(query)

agent = Agent(
    model='claude-sonnet-4-20250514',
    tools=[search_web],
    system_prompt='You are a research assistant. Answer questions using web search.'
)
  1. Run the agent on a task:
result = agent.run('What are the latest developments in quantum computing?')
print(result.output)
§04

Example

Multi-tool agent with memory:

from claude_agent_sdk import Agent, tool, MemoryStore

@tool
def query_database(sql: str) -> str:
    'Execute a SQL query against the analytics database.'
    return db.execute(sql)

@tool
def send_email(to: str, subject: str, body: str) -> str:
    'Send an email notification.'
    return email_service.send(to, subject, body)

memory = MemoryStore(backend='sqlite')

agent = Agent(
    model='claude-sonnet-4-20250514',
    tools=[query_database, send_email],
    memory=memory,
)

# Agent remembers context across sessions
agent.run('Send a weekly revenue report to the finance team')
§05

Related on TokRepo

§06

Common pitfalls

  • Tool functions must have clear docstrings. The SDK sends docstrings to Claude as tool descriptions. Vague docstrings lead to incorrect tool selection.
  • Memory persistence requires explicit configuration. Without a memory backend, agent context is lost between sessions.
  • Long-running agent tasks can accumulate significant token costs. Set max_turns or token budgets to prevent runaway execution.
  • Always check the official documentation for the latest version-specific changes and migration guides before upgrading in production environments.
  • For team deployments, establish clear guidelines on configuration and usage patterns to ensure consistency across developers.

Frequently Asked Questions

What models does the Agent SDK support?+

The Agent SDK is designed for Claude models. It supports Claude Sonnet, Claude Opus, and Claude Haiku. The SDK handles model-specific features like extended thinking and tool use automatically.

How does memory work in the Agent SDK?+

The MemoryStore persists conversation history and key facts across agent sessions. It supports SQLite and PostgreSQL backends. The agent can recall previous interactions and decisions without re-establishing context.

Can I use the Agent SDK for multi-agent systems?+

The SDK focuses on single-agent orchestration with tools. For multi-agent systems with coordination between agents, you can compose multiple SDK agents or use a multi-agent framework that delegates to SDK agents.

How does error recovery work?+

When a tool call fails, the SDK captures the error, includes it in the conversation context, and lets Claude retry with awareness of what went wrong. This handles transient failures like network timeouts without manual intervention.

What is the difference between the Agent SDK and the Anthropic Python SDK?+

The Anthropic Python SDK provides low-level API access for single completions. The Agent SDK adds the agent loop, tool orchestration, memory, and production guardrails on top. Use the Python SDK for simple API calls; use the Agent SDK for autonomous agent applications.

Citations (3)
🙏

Source & Thanks

Created by Anthropic. Licensed under MIT.

anthropics/claude-agent-sdk — Official Anthropic Agent SDK

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.