camelRun by camelAI
Durable AI agents that outlive any server
camelRun runs durable AI agents in SQLite Durable Objects with persisted state, resumable SSE streams, and instant forks through restarts.camelRun is a hosted runtime for durable AI agents. Each agent runs in its own SQLite Durable Object with persisted history, a versioned camelFS workspace, and queued work. When a worker restarts or your app reconnects, runs pick up from stored state, SSE streams resume from their last sequence number, and you can fork any agent at any step.
Worker 3 interrupted mid-webhook. Worker 1 reloaded state, and order 1042 completes via the signed callback keyed on callId.
Persisted run state
Agents keep working across restarts
Every turn, tool result, and event is written to the agent's SQLite Durable Object. When a worker recycles during a deploy, the runtime reloads the persisted state at the last committed step and keeps going.
Every event carries a monotonic sequence number. Reconnect with after or Last-Event-ID to pick up the stream with no gap and no repeated frames.
Read about eventsid: 414event: tool_call_enddata: {"seq":414, "runId": "run_8c1f…", "type": "tool_call_end", "data": {"name": "refund", "ok": true}}State persisted in SQLite Durable Object
GET /v2/agents/ops/events?after=414Last-Event-ID: 414
id: 415event: run_resumeddata: {"seq":415, "runId": "run_8c1f…", "type": "run_resumed", "data": {"runId": "run_8c1f…"}}
id: 416event: text_deltadata: {"seq":416, "runId": "run_8c1f…", "type": "text_delta", "data": {"delta": "Refund #1042 issued."}}
id: 417event: run_completeddata: {"seq":417, "runId": "run_8c1f…", "type": "run_completed", "data": {"runId": "run_8c1f…"}}
Safe side effects
Explicit idempotency for external side effects
camelRun records every completed model step and tool result in durable storage before advancing. For side effects like refunds or billing calls, use an HTTPS webhook tool with async: true: return 202 Accepted, key the mutation on callId, and POST the outcome to the signed callback URL—where repeats safely return duplicate.
Pass callId into any downstream mutation with side effects. If a worker restarts or your service retries the callback, the external action still executes once.
// Your HTTPS webhook tool: verify the runtime JWT, key the refund by callId.
app.post("/tools/refund", async (req, res) => {
await verifyRuntimeJwt(req.headers.authorization);
const { callId, args, callback } = req.body;
queueRefund({ orderId: args.orderId, idempotencyKey: callId, callback });
return res.status(202).json({ accepted: true });
});When your app restarts
Stateful AI agents that keep going when your app restarts
The same key reaches the same agent from any server, because the run lives in camelRun instead of your process. Use HTTPS webhook tools or remote MCP servers so your own app deploys never break an active call.
Sleep and wake
Long-running AI agents that sleep at zero cost
Between runs—or while waiting on a human approval, sub-agent, or async webhook callback—an agent hibernates at $0. A prompt, a schedule, a Slack message, or a webhook wakes it on demand with its full history and files intact.
People in the loop$0.05 per active agent-hour
$0 (storage currently unmetered)
FAQ
Questions about durable AI agents
What makes an AI agent durable?
A durable AI agent keeps its state outside your application process. In camelRun, every keyed agent runs in its own Cloudflare SQLite Durable Object with persisted history, a versioned camelFS workspace, schedules, and pending inputs. It hibernates when idle and picks up where it left off whenever a prompt, schedule, or webhook arrives.
Do I have to write my agent as a workflow to make it durable?
No. camelRun runs the model loop and persists every turn automatically—just upsert an agent with PUT /v2/agents/:key and send prompts to POST /v2/agents/:key/runs with an idempotencyKey. When you do want multi-step deterministic code replay across agents, v2 also provides POST /v2/agents/:key/workflows.
What happens to a running agent during a deploy or worker restart?
Steps, tool results, and event records are persisted in the agent's SQLite Durable Object. When a worker restarts, the runtime resumes from the last committed state instead of starting over. Any client watching GET /v2/agents/:key/events reconnects with after or Last-Event-ID and continues receiving monotonic sequence numbers without gaps.
How does camelRun prevent duplicate side effects on retries?
Send an idempotencyKey on POST /v2/agents/:key/runs so retried requests return the existing run instead of starting a second one. For external side effects like billing or refunds, use an HTTPS webhook tool with async: true: key your downstream action on callId, return 202 Accepted, and POST the outcome to the signed callback URL where duplicate deliveries are safely ignored.
Does a durable agent keep its state and files between sessions?
Yes. The same key always reaches the same agent until you delete it. Full history stays readable through a paged API, older messages are compacted for the model as conversations grow, and files live in a versioned camelFS repo. You can also create an instant copy-on-write fork of the agent and its repo at any sequence number with POST /v2/agents/:key/fork and atSeq.
How is a durable agent billed while it is idle or parked?
Idle, queued, and parked agents cost $0—including time spent waiting on human approval, a child agent, or an async webhook callback. Active agent time is $0.05 per active agent-hour, active Linux container execution (`bash`) is $0.00005/sec ($0.18/hr) with free pre-warming, and storage is currently unmetered. Model tokens are $0 from camelRun on BYOK, or billed at the provider's price with no markup on direct providers.
What if my own app restarts in the middle of a run?
Runs execute inside camelRun, not your server. If your tools are HTTPS webhooks or remote MCP servers, deploying or restarting your app does not disrupt active runs—just re-send the same idempotencyKey to retrieve the run record. Local tools served over an SDK WebSocket require an open connection and will fail an in-flight call if the socket disconnects.
Do I need my own database or queue to run durable agents?
No. Each agent's history, queued prompts, and camelFS files live inside camelRun, so you do not need to manage a separate session store or worker queue. The runtime is open source under AGPL-3.0 on GitHub: you can deploy to your own Cloudflare account with Wrangler (Workers, SQLite Durable Objects, R2, and Containers), or test experimental self-hosting on your own machines with celld.
Keep reading
More on durable agents
Start your first durable agent
Sign in to the console, create a cr_live_ API key, and run your first keyed agent over REST. Or connect your coding agent directly to camelRun's hosted MCP server.
const BASE = "https://run.camelai.com";
const headers = {
Authorization: `Bearer ${process.env.CAMELRUN_API_KEY}`,
"Content-Type": "application/json",
};
// PUT upserts by key: the same key is the same agent, with its history.
await fetch(`${BASE}/v2/agents/quickstart`, {
method: "PUT",
headers,
body: JSON.stringify({ instructions: "You are a concise assistant." }),
});
// Start a durable run and wait for the finished RunRecord.
const res = await fetch(`${BASE}/v2/agents/quickstart/runs`, {
method: "POST",
headers,
body: JSON.stringify({ prompt: "Write a haiku about durable agents.", wait: true }),
});
const run = await res.json();
console.log(run.text);CAMELRUN_API_KEY=cr_live_... node quickstart.tsclaude mcp add --transport http camelrun https://run.camelai.com/mcp
Adds camelRun's hosted MCP server to Claude Code (also works with Codex and ChatGPT). Signing in creates your account automatically.