Concepts
camelRun v2 concepts: durable agents, runs, CamelFS, and tools
How camelRun v2 works: durable keyed agents, CamelFS repos and session VMs, runs, queue and steer modes, compaction, dreaming, forking, and tools.
camelRun v2 is built around two primitives: durable keyed agents (AgentDO) and Git-backed repositories with session VMs (CamelFS). Every piece of agent state (configuration, conversation history, compactions, runs, pending inputs, schedules, workflow step caches, and voice sessions) persists in camelRun rather than your application process.
Durable keyed agents
You address an agent by its key (your own identifier such as user-123 or thread-9f2c) or its generated id (agt_...).
const agent = await client.agents.upsert("user-123", {
model: "azure/gpt-6.2-sol",
instructions: "You help users troubleshoot deployments.",
builtins: ["files", "bash", "web_search", "human"],
repoId: repo.repoId,
branch: "refs/heads/main",
spendLimitUsd: 10,
idleTtlSeconds: 86400,
});PUT /v2/agents/:keycreates the agent on first call (201) and updates its configuration on subsequent calls (200), preserving conversation history.- You can pass
promptdirectly inPUT /v2/agents/:keyto create or update the agent and kick off its first run in a single HTTP round-trip. - Each agent receives a scoped
agentToken(agt_tok_<tenantId>.<agentId>.<secret>). That token can run, stream, read history, and answer non-signed inputs on that single agent, and returns403on deletion or config changes. idleTtlSecondscontrols automatic expiration after inactivity.- Deleting an agent (
DELETE /v2/agents/:idOrKey) cancels in-flight work, destroys its Durable Object state, and frees the key.
CamelFS repositories and session VMs
Mutable v1 volumes and multi-path mounts are replaced in v2 by CamelFS, a content-addressed Git-like repository service (/v2/repos):
- An agent binds to at most one repository (
repoId) and branch (branch, defaultrefs/heads/main). If you omitrepoIdand enable file or bash tools, camelRun provisions a repository automatically (or you can callPUT /v2/agents/:idOrKey/repo). - Inside the agent's session VM (
builtins: ["bash"]), the bound repository is mounted at/workspacewith a persistent bash shell. Every command runs atomically and commits changed files back to the branch. - File tools (
builtins: ["files"]) and the/v2/repos/:repoId/*API read and write commits directly. When a VM is active for the same agent, CamelFS applies API/tool file writes directly into the live/workspaceand commits the new tree without conflicts.
See Files and CamelFS.
Runs, queueing, and steering
Sending a prompt to POST /v2/agents/:idOrKey/runs creates a run (RunRecord) with status queued, running, input_required, completed, failed, or cancelled.
An agent executes one active run at a time. You control what happens when a new prompt arrives while a run is active:
| Setting | Behavior |
|---|---|
whileRunning: "queue" (default) | Enqueues the prompt to execute after the active run finishes. |
whileRunning: "steer" | Injects the prompt mid-turn into the active run after its current step (emitting steer_applied). The steer run sets batchedInto to the active run ID. |
Key rules for steering and queueing:
- Spend limits require queueing: A run that specifies
spendLimitUsdmust usewhileRunning: "queue". PassingspendLimitUsdwithwhileRunning: "steer"returns400 invalid_spend_limit. Steering an active run keeps the active run's existing spend limit. - Attachments require queueing: Runs with
filesattachments must usewhileRunning: "queue"and a configured repository. - Actor isolation: If you pass
actor(requires a tenant API key), a steer from a differentactorthan the active run queues as its own run instead of steering. - Batch queue mode: Configuring
queue: { mode: "batch", windowMs: 1500 }merges consecutive queued prompts arriving withinwindowMsinto a single turn (follower runs recordbatchedInto). Runs with a per-runspendLimitUsdor anactoralways execute individually, even in batch mode.
Waiting, polling, and aborting
wait: true(default) waits for the run to settle before returning. Passwait: false(or callagent.submit()) to return thequeuedrun immediately and follow it over SSE (GET /v2/agents/:idOrKey/events) or pollGET /v2/agents/:idOrKey/runs/:runId.- Pass
idempotencyKeyto make retries safe. Look up a run by key atGET /v2/agents/:idOrKey/runs/:key?by=idempotency-key(agent.getRunByKey(key)). POST /v2/agents/:idOrKey/abort(agent.abort()) aborts the active run and cancels queued runs. Pass{ keepQueued: true }to abort only the active run and let queued runs proceed.
Compaction, context reset, and dreaming
Automatic and manual compaction
As conversation history grows toward the model's context window, camelRun compacts older messages into a summary while preserving the full raw message log in GET /v2/agents/:idOrKey/history.
- Trigger compaction manually with
POST /v2/agents/:idOrKey/compact(agent.compact({ summary?, keepLast? })). - Reset the model's active context with
POST /v2/agents/:idOrKey/reset-context(agent.resetContext({ summary?, keepLast? })). WithkeepLast: 0and nosummary, messages and compactions are cleared; otherwise a new compaction boundary is recorded at the cutoff.
Dreaming (memory consolidation)
When dreaming: { enabled: true, idleSeconds: 3600 } is configured on an agent, camelRun runs a background memory-consolidation pass after the agent has been idle for idleSeconds, summarizing recent work into /workspace/MEMORY.md in the agent's repository and emitting dream_completed. You can also trigger it on demand with POST /v2/agents/:idOrKey/dream (agent.dream()).
Forking
POST /v2/agents/:idOrKey/fork (agent.fork({ key?, atSeq? })) creates a new independent agent from an existing one:
- Copies the source agent's configuration, messages up to
atSeq(or the latest sequence), and applicable compaction summary. - Forks the source agent's CamelFS repository lineage so the forked agent gets its own independent repo and commit history sharing underlying content-addressed objects.
- Returns
{ id, key, agentToken, repoId, lineage, branch, commit, forkedFrom: { agentId, atSeq } }.
Where tools run
| Mechanism | How you configure it | Best for |
|---|---|---|
| Local WebSocket tools | Pass defineTool({ name, description, parameters, execute }) in tools | Long-lived servers or local scripts where tools run in your process over /v2/agents/:idOrKey/ws |
| HTTP webhook tools | Pass { name, description, parameters, url, headers?, requiresApproval? } in tools | Stateless HTTP endpoints, serverless functions, and multi-worker backends |
| Remote MCP servers | Pass mcpServers: [{ name, url, headers?, auth?, audience?, allowTools? }] | Third-party MCP servers or your own signed tool servers using runtime JWTs (auth: { type: "runtime" }) |
| Built-in suites | Pass builtins: ["files", "images", "bash", "codemode", "delegate", "workflows", "web_search", "web_fetch", "human"] | Ready-made workspace files, SVG rendering, Firecracker bash VMs, QuickJS codemode, sub-agents, replay workflows, web access, and human input |
See Tools for full details and schemas.
People in the loop
A run pauses with status: "input_required" whenever:
- The model calls
ask_human(builtins: ["human"]). - The model calls a custom tool configured with
requiresApproval: true. - A signed MCP server (
auth: { type: "runtime" }) returnsresultType: "input_required"requestingagent-runtime/approvalorelicitation/create(formorurlmode).
Inspect pending inputs with GET /v2/agents/:idOrKey/inputs and resume the run with POST /v2/agents/:idOrKey/inputs/:inputId (agent.answerInput(inputId, { approved, answer, wait, actor })). See Human input.
Definitions, schedules, and stateless runs
- Definitions (
PUT /v2/definitions/:slug): Reusable agent configurations referenced bydefinition: "<slug>"when upserting agents or creating channels. See Definitions. - Schedules (
POST /v2/agents/:idOrKey/schedules): Recurring wake-ups viaintervalSecondsorcronExpr. See Schedules and dreaming. - Stateless runs and decisions: One-shot calls at
POST /v2/runsand classification atPOST /v2/decisionswithout persisting an agent. See Stateless runs and decisions.