Operate durable AgentWorks runs and interactions
An AgentWorks run is one durable piece of work, permanently pinned to the release, deployment revision, and invoker that started it. The runtime records the run before a worker executes it, and keeps its events, checkpoints, and external-effect decisions in its own SQLite file. A runtime that stops and restarts on the same file continues accepted work from its last checkpoint without repeating an effect it recorded.
How do you start and follow a run?
Find the deployment id with GET /api/v1/deployments, then start a run on it. Replace <caller-key> with a caller key
from the runtime file, and <deployment-id> with the id from the list:
curl --fail -X POST "http://127.0.0.1:8080/api/v1/deployments/<deployment-id>/runs" \
-H "Authorization: Bearer <caller-key>" \
-H "Idempotency-Key: kyc-check-2026-11-17-0042" \
-H "Content-Type: application/json" \
-d '{"input": {"prompt": "Check customer C-1042 before account opening."}}'
The answer is 201 Created with a Location header naming the run, and the run's pins and summary. An excerpt:
{
"id": "0b8f4c2e-6a51-4d3e-9a7c-2f1e8d5b7c90",
"deploymentId": "5d2a9f10-3c4b-4e8a-b1d6-7a0c9e2f4b13",
"releaseId": "9e7c1a42-8b3d-4f5e-a6c0-1d2b3e4f5a67",
"lifecycle": "QUEUED",
"traceId": "4bf92f3577b34da6a3ce929d0e0e4736",
"eventSequence": 1
}
Repeating the same request with the same Idempotency-Key returns the original run instead of starting a second one.
A run stays QUEUED until a worker is enabled (agentworks.runs.worker.enabled=true) and the model gateway is
configured. Its lifecycle is one of CREATED, QUEUED, ACTIVE, BLOCKED, PAUSED, SUCCEEDED, FAILED, or
CANCELLED.
Follow it through these surfaces:
| Task | API | CLI |
|---|---|---|
| Show pins, state, usage, and result | GET /api/v1/runs/{id} | agentworks run show <run-id> |
| List runs, newest first | GET /api/v1/runs | agentworks run list |
| Page through ordered events | GET /api/v1/runs/{id}/events | agentworks events list <run-id> |
| Follow events live | GET /api/v1/runs/{id}/stream | agentworks stream <run-id> |
| Read the step projection | GET /api/v1/runs/{id}/steps | — |
| Cancel | POST /api/v1/runs/{id}/cancel | agentworks run cancel |
| Pause at the next safe boundary | POST /api/v1/runs/{id}/pause | agentworks run pause |
| Resume a paused run | POST /api/v1/runs/{id}/resume | agentworks run resume |
| Plan, then start, a replay | GET /api/v1/runs/{id}/replay/plan, POST /api/v1/runs/{id}/replay | agentworks replay plan, agentworks replay start |
The stream is Server-Sent Events. Each event's id is <runId>:<sequence>; reconnect with Last-Event-ID to continue
without a gap. A run that is not in the caller's workspace answers 404, and a run in the wrong state for an action
answers 409 with a typed code such as RUN_TERMINAL.
What does pause guarantee?
A queued run pauses at once. An active run pauses at its next safe boundary: after a checkpoint, before an effect, at a
recovery claim, or before a model round. It never pauses while an effect is in doubt. An executor that cannot resume
its current exchange without repeating work refuses the pause with 409 PAUSE_UNSAFE; treat that as protection, not
as a transient error. Resume returns the same pinned run to the queue.
A caller's pause request, its withdrawal, and a cancel are recorded in the run store in the same transaction as the
change, with the caller and how they signed in. A headless runtime serves these records at
GET /api/v1/administrative-audit; a runtime enrolled with Flightdeck hands each one to Flightdeck's audit.
What does durable execution guarantee?
Workers hold fenced leases (agentworks.runs.worker.lease-duration, default 30 seconds) and renew them while a model
or tool call is in flight. If a process stops answering for longer than the lease, another worker of the same runtime
takes the run over and continues from its recorded state: a tool call that completed is not called again, and its
recorded result is used. Only the model call that was in flight is repeated.
No runtime can make an external system exactly-once. If a connection fails after the external action but before its result is recorded, the outcome is recorded as uncertain. Give consequential tools their own idempotency key and a reconciliation operation.
How does a run wait for a person?
A run can open a typed human interaction and block without holding a worker. The kinds are APPROVAL, QUESTION,
SELECTION, FORM, CONFIRMATION, and AUTHORIZATION, and each interaction carries the same run pins as the work
that asked. List open ones and answer one:
agentworks interaction list --status OPEN
curl --fail -X POST "http://127.0.0.1:8080/api/v1/interactions/<interaction-id>/response" \
-H "Authorization: Bearer <caller-key>" -H "Content-Type: application/json" \
-d '{"approved": true}'
The body holds exactly one property that matches the kind: approved, answer, optionIds, fields, confirmed,
or granted. Only the assigned principal may answer (UNAUTHORIZED_RESPONDER otherwise), and exactly one outcome
resumes the run: a repeat is 409 ALREADY_TERMINAL. An operator with RUN_ADMIT can expire an interaction whose
deadline has passed (DEADLINE_NOT_REACHED before then), cancel it, or revoke an authorization.
Cancelling a run that waits on a person ends its open interaction in the same transaction, so a late answer is refused. Never put a secret in interaction text, and treat submitted values as untrusted run input.
How do sessions, operations, and child runs resume work?
- Sessions (
/api/v1/sessions) serialize deduplicated messages for a conversation or an external thread that outlives one request. A message without arunIdstarts a run on the session's deployment. A message to a run that is still working goes to that run's inbox: aspring-airun reads its pending messages before every model round, never during a model or tool call, and recordsINBOX_MESSAGE_RECEIVEDandINBOX_MESSAGE_CONSUMEDfor each. - Durable operations (
/api/v1/operations) let a run start a long external activity, release its worker, and continue from an authenticated callback or bounded polling. The terminal result is accepted once. - Child runs get their own release and execution identity, a narrowed budget, and recorded parent and root lineage. Parent cancellation propagates, and a child's completion resumes the parent once.
- Scheduled wake-ups resume an existing run with its original pins; they never re-resolve the deployment.
None of these changes a run's release or deployment pins.
How does a run ask its caller a question?
The built-in tool ask_caller (agentworks:ask-caller:1.0.0) lets an agent ask the run's caller a free-text
question and wait for the answer. The agent offers it through a capability pack and a permission, like any tool (see
built-in tools), and needs execution: {initialIntent: EXECUTE}.
- The call opens a
QUESTIONinteraction assigned to the run's invoker, and the run blocks with no worker held. - The caller answers with
POST /api/v1/interactions/{id}/responseand{"answer": "..."}, or, over A2A, with amessage/sendthat names the task. - The run repeats its exchange, and the same question gets the answer as the tool's result.
Only the run's invoker may answer; anyone else is refused with UNAUTHORIZED_RESPONDER, and the run keeps waiting. A
question waits 24 hours. Once its deadline has passed, an operator can expire it; it can also be cancelled or revoked.
The run then resumes, and the agent's result says that no answer came. Nothing expires a question by itself, so watch
open interactions. ask_caller does not use the tool-effect ledger: the question is its own durable record.
How do A2A tasks map to runs?
A deployment exposed as an A2A agent (agentworks.a2a.exposures.<id>.*) turns each message/send into a run, admitted
exactly as POST /api/v1/deployments/{id}/runs admits it. In 1.16.0, a message that names an existing task continues
it:
| The task is | A message/send naming it |
|---|---|
| Working, on an executor that reads its inbox | Goes to the run's inbox, in one session per contextId, and the answer is the same task, still working. A repeated messageId stores nothing more. |
input-required because the run called ask_caller | Answers the question as the caller and continues the same task. message/send then waits, as for a new task. |
| Working, on an executor that reads no inbox | Refused with -32004. |
| Ended | Starts a new task in the same contextId, which names the ended one in referenceTaskIds. |
| Not one of the caller's tasks of this exposure | Refused with -32001. |
Only the spring-ai executor reads its inbox. tasks/get with historyLength shows each message sent while the task
worked, with metadata dvara.inbox set to read or pending; a run that ends before its next safe point never
reads a pending one. A task is input-required only while its run waits on a person or an authorization, and
message/send answers as soon as its task needs input instead of waiting for wait-timeout. tasks/cancel cancels
the run as the run API does.