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

ParameterTypeDefaultDescription
namestrNoneDisplay name for the agent.
idstrNoneUnique identifier. Auto-generated from name if unset.
system_promptstrNoneOptional system prompt.
modelstrNoneModel id (e.g. "claude-sonnet-4-6"). Defaults to the SDK default.
allowed_toolsList[str]NoneTools to auto-approve (e.g. ["Read", "Bash", "WebSearch"]), not an exclusive tool allowlist. Unlisted tools follow the SDK permission policy.
disallowed_toolsList[str]NoneTools to block.
permission_modestrNoneForwarded to the SDK; see its current permission modes.
max_turnsintNoneMaximum number of turns per run.
max_budget_usdfloatNoneStopping threshold for the SDK's client-side USD cost estimate; not a hard billing cap. See the SDK reference.
cwdstrNoneWorking directory the agent runs in.
mcp_serversDict[str, Any]NoneMCP server configurations for custom tools.
options_kwargsDict[str, Any]{}Extra kwargs forwarded to ClaudeAgentOptions.
dbBaseDbNoneDatabase 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

Developer Resources