Claude Agent SDK
Run Claude Code as an AgentOS agent using ClaudeAgent.
ClaudeAgent wraps the Claude Agent SDK so Claude Code can be served through AgentOS.
Tool execution is handled by the SDK. You configure tool permission rules and the SDK permission mode.
Save the following as claude_agent.py. After the Install step, start it with python claude_agent.py. Later snippets are alternatives or fragments using the same imports.
from agno.agents.claude import ClaudeAgent
from agno.db.sqlite import SqliteDb
from agno.os import AgentOS
agent = ClaudeAgent(
name="Claude Code Agent",
model="claude-sonnet-4-6",
allowed_tools=["Read", "Edit", "Bash"],
permission_mode="acceptEdits",
max_turns=10,
)
agent_os = AgentOS(
agents=[agent],
tracing=True,
db=SqliteDb(db_file="tmp/agentos.db"),
)
app = agent_os.get_app()
if __name__ == "__main__":
agent_os.serve(app="claude_agent:app", reload=True)Install
uv pip install "agno[os]" claude-agent-sdk
export ANTHROPIC_API_KEY=sk-ant-...Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
name | str | None | Display name for the agent. |
id | str | None | Unique identifier. Auto-generated from name if unset. |
system_prompt | str | None | Optional system prompt. |
model | str | None | Model id (e.g. "claude-sonnet-4-6"). Defaults to the SDK default. |
allowed_tools | List[str] | None | Tools to auto-approve (e.g. ["Read", "Bash", "WebSearch"]), not an exclusive tool allowlist. Unlisted tools follow the SDK permission policy. |
disallowed_tools | List[str] | None | Tools to block. |
permission_mode | str | None | Forwarded to the SDK; see its current permission modes. |
max_turns | int | None | Maximum number of turns per run. |
max_budget_usd | float | None | Stopping threshold for the SDK's client-side USD cost estimate; not a hard billing cap. See the SDK reference. |
cwd | str | None | Working directory the agent runs in. |
mcp_servers | Dict[str, Any] | None | MCP server configurations for custom tools. |
options_kwargs | Dict[str, Any] | {} | Extra kwargs forwarded to ClaudeAgentOptions. |
db | BaseDb | None | Database for session persistence. |
Session persistence
A configured db persists Agno session and run records. The adapter maps Agno sessions to Claude SDK session IDs in process memory and resumes through that map. After a restart or on another replica, stored Agno history alone does not restore the SDK conversation: the adapter does not replay that history into the SDK. Plan conversation routing and restart behavior accordingly.
Examples
AgentOS deployment
Serve a Claude Code agent through AgentOS.
Standalone usage
Call the agent directly with .run() and .print_response().
Custom MCP tools
Extend Claude Code with your own MCP servers.
Sessions
Resume conversations across runs with session_id.