Ports
Run agents
Agents are the platform's reasoning layer: a durable harness that plans, calls KB and data tools, respects budgets and guardrails, and pauses for human approval on sensitive actions. The /api/v1/agents surface drives the exact same harness the UI uses. This guide queues a run, reattaches to its stream, reads the trace, resolves an approval, and records feedback.
Prerequisites
- A key with
agents:run(start/cancel/approve/feedback) andruns:read(inspect). - An agent published in the workspace, identified by its
slug. - An enabled chat model — an unconfigured slot returns
409 no-model-configured.
Concepts first, if you want them: Agents & the harness and Tools, MCP & HITL.
Start a run
Runs are addressed by the agent's slug. The normal start returns HTTP 202 as soon as the queued run is the durable handoff record. Save both the id and the returned stream URL. The initial pg-boss send uses a stable identity; worker boot/minute reconciliation reconstructs the same pinned start if the request process or broker failed between row commit and queue acceptance.
/api/v1/agents/{slug}/runsBearer · agents:runPersist and queue a durable run of the named agent.
Request body
Reattach with GET /api/v1/runs/{id}/stream and the runs:read scope. The stream replays persisted steps and then tails the database, so a disconnect or another web replica does not lose execution state.
Legacy inline SSE
?stream=inline to the start URL only when an older client requires one in-request stream. It is an explicit compatibility path, not the durable default.Terminal statuses
queued · running · succeeded · failed · budget_exceeded (graceful stop; text holds the partial answer) · interrupted · suspended (awaiting a human decision — resolve with /approve). Budget exhaustion is not an error: the run ends cleanly with what it has.Inspect a run
Every run persists a full, ordered step trace — model calls, tool calls, guardrails, approvals, retries — with token and cost accounting. Read it to debug, to audit, or to show a user how the answer was reached.
/api/v1/runs/{id}Bearer · runs:readFetch a run and its ordered step trace. A run in another workspace is invisible under RLS → 404.
For just the steps, GET /api/v1/runs/{id}/steps. To stop a run in flight, POST /api/v1/runs/{id}/cancel — worker runs poll a cancel flag between steps and stop cooperatively.
Resolve an approval
When a run calls a tool marked requires approval, it suspends with an approvalId and waits — the human-in-the-loop gate. Record the decision; the server atomically queues a worker continuation and returns 202. Keep following the original run stream.
/api/v1/runs/{id}/approveBearer · agents:runResolve a suspended HITL approval and queue a durable continuation.
Request body
Attach feedback
Close the loop by recording how a run did. Feedback is durable, attributed, and feeds evals and quality tracking.
/api/v1/runs/{id}/feedbackBearer · agents:runAttach human feedback to a completed run. Returns 201 with the feedback id.
Request body
Reference & error handling
The leverage
You are not calling a chat completion — you are triggering a governed, auditable worker that reasons over your knowledge graph and live data, stops for a human before it does anything risky, and leaves a complete trace behind. Wire it to a webhook, a queue, or a schedule and every automated decision comes with its own receipt. Every keyed run is attributed to its API key and counts against the workspace budgets, so automation never runs away with your spend.