What is a self-hosted AI agent?
An AI agent whose runtime (the agent loop, session history, tool execution, and credentials) runs on infrastructure you control. The model can still be a hosted API you call with your own key.
Self-hosted AI agents
Self-hosting an AI agent means running the part that matters for control: the agent loop, session history, tool sandbox, and credentials, on infrastructure you own, while still calling whichever model API you choose. An open managed runtime such as OpenMA provides those pieces as one deployable service.
The table compares the two vendor-managed agent runtimes with a self-hosted one on who runs each part and where data lives.
| Claude Managed Agents | OpenAI Agents API (managed harness) | Self-hosted runtime | |
|---|---|---|---|
| Who runs the agent loop | The vendor | The vendor | You |
| Where session history lives | Vendor cloud | Vendor cloud | Your database |
| Where tools execute | Vendor sandbox or self-hosted sandbox | Hosted or self-hosted sandbox | Sandbox provider you choose |
| Models | Claude | OpenAI | Any provider or gateway you configure |
| Credentials | Stored with the vendor | Stored with the vendor | Your vault and secret store |
| Operations | None for you | None for you | Your team |
Anthropic hosts the harness and sessions. Self-hosted sandboxes move only tool execution to your infrastructure. Read what Claude Managed Agents is, or compare Claude Managed Agents alternatives.
OpenAI runs the Codex-based harness, session state, and API. A self-hosted sandbox moves code execution to your infrastructure. See the OpenAI Agents API comparison.
This page is about self-hosting a managed agent runtime. Coding agents and agent frameworks can also be self-hosted, and the AI agent platform & orchestration guide explains how those categories differ.
Agents see sensitive context: tickets, code, customer records, tool output. Self-hosting keeps that history and the sandbox inside your network, region, and audit tooling.
Bring your own keys and pay providers directly. Route agents to different models by task, keep a fallback vendor, or use a private gateway, without changing the runtime.
With an open runtime you can read the harness, change context engineering, and pick the sandbox. The trade-off is that you also own upgrades and on-call.
The quickest local start is Docker Compose:
git clone https://github.com/openma-ai/open-managed-agents
cd open-managed-agents
cp .env.example .env # add a model provider key
docker compose up -d For production, follow the Node + Docker guide, or read how to self-host an agent platform on Cloudflare Workers. Node deployments scale out across replicas with shared PostgreSQL or MySQL.
OpenMA is an open-source managed agent runtime. It provides the same
building blocks as vendor-managed services (agents, environments,
sessions, events, vaults, memory stores) with a Claude Managed
Agents-compatible API at /v1 and an OpenAI Agents API
adapter at /openai/v1.
Your applications, integrations, and teams call it to run agents of any kind. Coding agents such as Claude Code and Codex can run inside it through ACP adapters. For the category view, see AI agent platform & orchestration.
Compare open-source AI agents by category, or go straight to the open-source managed agents shortlist.
An AI agent whose runtime (the agent loop, session history, tool execution, and credentials) runs on infrastructure you control. The model can still be a hosted API you call with your own key.
No. You can call hosted model APIs with your own keys, or point the runtime at a private gateway or an open-weight model server if your policy requires it.
Not the control plane. Claude Managed Agents supports self-hosted sandboxes, but the harness and sessions run on Anthropic. An open runtime such as OpenMA keeps the same API shape and runs entirely on your infrastructure.
For a single host, Docker Compose with SQLite. For production, a Node deployment with PostgreSQL or MySQL, object storage, and a sandbox provider, or the Cloudflare setup wizard. The self-host docs cover each path.
Compare hosted CMA with open, self-hosted runtimes.
Agent platforms vs frameworks vs coding agents.
Shortlist of open runtimes with the managed-agent shape.
Sessions, sandboxes, model routing, and durability.
End-to-end Workers, Durable Objects, and R2 guide.