Guides
camelRun v2 production checklist for AI agent apps
Operational checklist before shipping a camelRun v2 app: keys and tokens, spendLimitUsd, idempotency, signed MCP tools, webhooks, and CamelFS.
Review these checks before launching an application backed by camelRun v2.
Keys, tokens, and identity
- Keep tenant keys (
cr_live_...) on your server. Never ship a tenant API key to browsers or mobile clients. - Create separate API tokens per service or environment with
POST /v2/tokensso you can revoke one service (DELETE /v2/tokens/:id) without rotating others. - Use scoped agent tokens (
agt_tok_...) carefully. An agent token can run, stream, and read history for that single agent, and cannot delete it or answer signed MCP inputs or actor-bound inputs. - Verify signed MCP JWTs properly. For MCP servers with
auth: { type: "runtime" }, verify the Ed25519 signature againstGET /v2/.well-known/jwks.json, checkiss,aud,tenant,agent,sub,ctx, andact, and enforce your own authorization checks before mutating data. - Never trust model arguments for tenant or user IDs. Always read user identity from the verified runtime JWT (
sub,act,ctx), never from tool input parameters.
Runs, retries, and spend protection
- Always pass
idempotencyKeyonPOST /v2/agents/:idOrKey/runs. Retrying a timed-out HTTP request with the same key returns the existing run instead of double-billing or duplicating turns. - Set both agent-level and per-run
spendLimitUsd. Remember that per-runspendLimitUsdrequireswhileRunning: "queue"(never"steer"). - Use
PATCH /v2/agents/:idOrKey/modelandPATCH /v2/agents/:idOrKey/spend-limitfor compare-and-swap updates when switching models or budgets on live agents. - Pass
actoron multi-user runs. This binds pending inputs to that actor (403 input_actor_mismatchfor anyone else) and includesactin signed MCP tool JWTs. - Monitor
busyAgentsand balance. PollGET /v2/meorGET /v2/billingand alert before reachingconcurrencyLimitor lowbalanceUsd.
Tools and deployment topology
- Prefer HTTP webhook tools or signed MCP servers in production web apps. Local WebSocket tools (
defineTool) require a live process connected to/v2/agents/:idOrKey/wsand time out after 30 seconds. HTTP webhook tools and MCP servers survive rolling deploys, autoscaling, and scheduled wake-ups. - Handle tool idempotency. Signed MCP
tools/callrequests include_meta["agent-runtime/idempotencyKey"]which stays identical across human-approval resumes. Key side effects (payments, emails, deploys) by it. - Configure
requiresApproval: trueor MCPagent-runtime/approvalon destructive actions.
Files and CamelFS
- Use
expectedCommiton concurrentPOST /v2/repos/:repoId/writecalls to avoid clobbering edits. - Pin attachments by commit. Always write user uploads with
POST /v2/repos/:repoId/writeand pass{ path, commit, contentType }infiles. - Use
repo_checkpointor record commit SHAs before risky agent runs so you can roll back withPOST /v2/repos/:repoId/restore.
Webhooks and streaming
- Verify
X-CamelRun-Signatureon every webhook. Check both the HMAC-SHA256 digest over${timestamp}.${rawBody}and timestamp freshness before processing. See Webhooks. - Use
Last-Event-IDor?after=<seq>&follow=1on SSE reconnects so browser or backend consumers resume cleanly when a stream closes on deploy or idle disconnect. - Treat
RunRecordas the source of truth. Use SSE events for live progress UI, and readGET /v2/agents/:idOrKey/runs/:runIdorrun.completedwebhooks for durable state transitions.