Implementation: DESIGN (server) · Exposure: PUBLIC PREVIEW (contract). The Agency API is not live yet. This page describes the published v0.3 contract so you can review and build against it; details may change before alpha.
This walkthrough shows one run from start to finish against the v0.3 contract. The endpoints are not live, so the code will not run against production today. It shows what an integration will look like. The alpha opens only after a run can survive restart, resume, verify, replay and receipt-backed completion.
The examples use curl, the built-in fetch in Node.js 18 or later, and the Python requests library. There is no SDK dependency.
Setup
1. Create a run
Only goal is required. Idempotency-Key is required on this call. Generate one key per logical request and reuse it if you retry.
The response is 202 Accepted with a Run. The run is already persisted. Read run.resolved to see the workspace, authority profile, budget and completion criteria the server resolved for you. Nothing executes before those are recorded.
If the server cannot resolve safe defaults you get 422 ERR_DEFAULTS_UNRESOLVABLE and no run is created. Supply the missing field explicitly:
2. Stream events
Open the run’s event stream with Accept: text/event-stream. Each message has an id, an event type and a JSON data line. Keep the last id you processed. If the connection drops, reconnect with Last-Event-ID and delivery restarts strictly after that event.
The stream closes after the terminal run.status_changed event (data.terminal is true). If it closes earlier, reconnect with the last id. You can also poll the same endpoint with Accept: application/json. See Events.
3. Answer an attention request
When the run needs a person it emits attention.requested and its status becomes needs_attention. The event’s data is an AttentionRequest. Read kind, reason, proposed_action and response_options before answering.
Answer it. The first valid response wins and is receipted before it takes effect.
An approval only resolves a policy ask. It cannot override a hard policy deny; that returns 403 ERR_POLICY_DENIED. An approval request that expires unanswered is treated as a rejection. After answering, keep reading the event stream (reconnect with Last-Event-ID if you closed it).
4. Check the result
When the stream ends, fetch the run. status tells you how it ended and completion shows each criterion with the receipts that back it.
A run is completed only when every required criterion has a passing verification receipt. The agent reporting that it is finished does not complete a run. See Verification.
5. Fetch artifacts
Artifacts are immutable and content-addressed. hash lets you check the bytes you downloaded. receipt_id points at the receipt that recorded the artifact.
6. Fetch receipts and verify the chain
List the run’s receipts in chain order, following next_cursor until has_more is false. Then check the chain.
The link check above confirms the chain is ordered and unbroken. To also confirm that each receipt’s content matches its hash and that each signature is valid, recompute the hashes and verify the Ed25519 signatures with the public keys at /.well-known/jwks.json. Complete code for that is in Receipts: verify independently.
Last, confirm that the run’s terminal receipt is part of the chain you verified:
What to read next
- Runs for pause, resume, cancel and steering
- Events for every event type
- Idempotency for safe retries
- Errors for the error envelope and codes
- Campaigns for objectives that run over time