camelAI Documentation

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.

View as Markdown

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/tokens so 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 against GET /v2/.well-known/jwks.json, check iss, aud, tenant, agent, sub, ctx, and act, 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 idempotencyKey on POST /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-run spendLimitUsd requires whileRunning: "queue" (never "steer").
  • Use PATCH /v2/agents/:idOrKey/model and PATCH /v2/agents/:idOrKey/spend-limit for compare-and-swap updates when switching models or budgets on live agents.
  • Pass actor on multi-user runs. This binds pending inputs to that actor (403 input_actor_mismatch for anyone else) and includes act in signed MCP tool JWTs.
  • Monitor busyAgents and balance. Poll GET /v2/me or GET /v2/billing and alert before reaching concurrencyLimit or low balanceUsd.

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/ws and 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/call requests include _meta["agent-runtime/idempotencyKey"] which stays identical across human-approval resumes. Key side effects (payments, emails, deploys) by it.
  • Configure requiresApproval: true or MCP agent-runtime/approval on destructive actions.

Files and CamelFS

  • Use expectedCommit on concurrent POST /v2/repos/:repoId/write calls to avoid clobbering edits.
  • Pin attachments by commit. Always write user uploads with POST /v2/repos/:repoId/write and pass { path, commit, contentType } in files.
  • Use repo_checkpoint or record commit SHAs before risky agent runs so you can roll back with POST /v2/repos/:repoId/restore.

Webhooks and streaming

  • Verify X-CamelRun-Signature on every webhook. Check both the HMAC-SHA256 digest over ${timestamp}.${rawBody} and timestamp freshness before processing. See Webhooks.
  • Use Last-Event-ID or ?after=<seq>&follow=1 on SSE reconnects so browser or backend consumers resume cleanly when a stream closes on deploy or idle disconnect.
  • Treat RunRecord as the source of truth. Use SSE events for live progress UI, and read GET /v2/agents/:idOrKey/runs/:runId or run.completed webhooks for durable state transitions.