AI Agents
Managed AI workers inside your workspace — scoped data access, budgets, sessions, approvals, and signed webhooks.
Managed agents inside your backend
An agent is a workspace asset: a managed AI worker with its own model, system prompt, data access, budget, and session limits. Your app triggers it (a support bot, an order assistant, a content generator), Codata runs it on the managed runtime, and every run is metered and auditable.
What you configure
- Model
- Choose from the supported model catalog; each run reports token usage and cost.
- System prompt
- The agent's instructions — generated for you with quality checks (grounding rules included).
- Data bindings
- Exactly which assets and fields the agent may read — an explicit whitelist, nothing else.
- Budget cap
- Monthly spend limit with alerts at 80% and 100%.
- Session limits
- Max turns per session and max tokens per turn.
- Built-in tools
- Optional
fetch_url(SSRF-protected) andweb_search.
Run lifecycle
Submit
Start a run with the user's input. The API accepts immediately and returns a run ID.
Execute
The agent runs with its data bindings — it can answer only from data it's allowed to see. Statuses:
queued → running → succeeded | failed(write-capable agents can pause atawaiting_approval).Collect
Poll for the result, stream output over SSE, or register an HTTPS callback — Codata signs webhook deliveries with HMAC so you can verify them.
Calling an agent from the SDK
const agent = ws.agent("supportBot");
// One-liner: submit + wait for completion
const run = await agent.run("Where is order #4512?", {
endUserId: user.id, // per-user sessions & rate limits
sessionId: previousSessionId, // continue a conversation thread
});
console.log(run.output, run.usage?.costUsd);
// Low-level: submit now, collect later
const submitted = await agent.submit(input, { callbackUrl, callbackSecret });
const result = await agent.getRun(submitted.runId);
// Write-capable agents: human approval gate
await agent.approve(runId);
await agent.reject(runId, "wrong customer");Sessions & multimodal input
- Sessions — pass
sessionIdto continue a conversation; older turns are digested automatically to stay within limits. - Images — send up to 4 images per run (https or data URLs) via the reserved
imagesinput key. - Idempotency — pass an
idempotencyKeyso retries never start duplicate runs.
Cost & guardrails
Every run response includes token usage and costUsd. Budget caps stop overspend, session limits stop runaway loops, and data bindings mean the agent can't read outside its whitelist. Generated system prompts include explicit "no evidence → say so and stop" grounding rules.
Agents can also be invoked by your connected coding assistant over MCP (workspaces-invokeAsset-write to start a run, workspaces-invokeAsset-read to poll) — useful for testing before wiring the SDK.