# Save Claude and Codex agents as versioned components

> Agno saves ClaudeAgent and CodexAgent configs as versioned components in your database, and AgentOS lists and runs them from GET /agents.

- Published: 2026-11-12
- Author: Yash Pratap Solanky
- Categories: Changelog
- Canonical: https://www.agno.com/blog/save-claude-and-codex-agents-as-versioned-components
- Markdown: https://www.agno.com/blog/save-claude-and-codex-agents-as-versioned-components.md

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.

```python
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:

```text
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.](https://www.agno.com/images/v3-2-0-external-agent-versions.png)

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](https://github.com/agno-agi/agno/blob/main/cookbook/93_components/external_agents.py), and learn more about [running Claude and Codex behind AgentOS](https://docs.agno.com/tutorials/harnesses-as-a-service) in the documentation.
