Skip to content
Changelog

Save Claude and Codex agents as versioned components

November 12, 20261 min read

Agno's ClaudeAgent and CodexAgent can now live in the database like an Agent, and AgentOS rebuilds the right adapter from the stored config on each request. That puts a Claude Code or Codex agent in GET /agents, GET /agents/{id} and the run routes without registering it in code.

agent = ClaudeAgent(
    id="claude-coder",
    model="claude-sonnet-4-6",
    permission_mode="acceptEdits",
    allowed_tools=["Read", "Grep", "Glob"],
    max_turns=10,
    db=db,
)
agent.save()  # version 1
agent.max_turns = 20
agent.save(label="more-turns")  # version 2
 
first = ClaudeAgent.load("claude-coder", db=db, version=1)
latest = get_agent_by_id(db=db, id="claude-coder")

The stored config names its adapter under sdk (claude-agent-sdk or codex) and keeps every non-default setting as JSON. The Registry resolves three references on load:

  • The database.
  • A Pydantic output_schema, by class name.
  • The sandbox, by its id.

A sandbox's env and clients never reach the database.

A stored agent without a sandbox appears in GET /agents but doesn't run by default, because its config names the working directory, MCP server commands and permission mode it would use on the AgentOS host. Give it a registered sandbox, or opt in with Registry(allow_host_execution=True). Otherwise AgentOS refuses the run with ComponentRehydrationError.

Settings that can't live in a config raise on save and say why. Any value that isn't JSON raises too, naming the field, so an MCP server entry that carries a live object stays out of storage:

ValueError: ClaudeAgent.mcp_servers cannot be stored as a component config: it holds a value that is not JSON (Object of type object is not JSON serializable). Keep live objects out of it, or register the agent in code instead.

Real output from saving a ClaudeAgent named claude-coder twice in SQLite. Version 1 has max_turns 10 and loads back with load(version=1); version 2, labelled more-turns, has max_turns 20 and is what get_agent_by_id returns. GET /agents lists claude-coder with is_component true, current_version 2 and sdk claude-agent-sdk. Saving with options=ClaudeAgentOptions raises a ValueError explaining that native ClaudeAgentOptions carry callbacks and services.

We captured this on a local SQLite file with no model key, so the saved agent was listed and loaded but never ran a turn.

Loading checks the adapter too. CodexAgent.load() on a Claude config raises ComponentRehydrationError, and so does Agent.from_dict, which earlier releases turned into a plain Agent without an error.

See the cookbook, and learn more about running Claude and Codex behind AgentOS in the documentation.

Frequently asked questions

Give the agent an id and a sync database such as SqliteDb or PostgresDb, then call agent.save(). It returns the new version number. Pass label= or stage= to tag it, and read it back with ClaudeAgent.load(id, db=db), CodexAgent.load(...) or get_agent_by_id(db=db, id=...). save() refuses async databases for now.

Claude options and options_kwargs, and Codex client_options, codex_bin and env. Saving a CodexAgent with env set raises ValueError: CodexAgent.env cannot be stored as a component config: process credentials; set them in the serving environment. Set those values on the serving AgentOS or its environment.

It appears in GET /agents next to code-registered agents, marked as a component. A local run returned {'id': 'claude-coder', 'name': 'Claude Coder', 'is_component': True, 'current_version': 2, 'stage': 'published', 'metadata': {'sdk': 'claude-agent-sdk'}}, and GET /components/claude-coder/configs listed versions 2 and 1.

No. A stored external agent runs on its own. Team.from_dict, workflow steps and the components API refuse it wherever an Agent is required, and the Studio member and step resolvers do the same.

Shipped around the same time