Browse documentation
Cancel active or queued work
Cancels one turn: the active turn, or the queued turn selected with
turn_id. Other queued turns are separate work. Requires run:write.
- An active turn returns
202and iscancellinguntil the runtime stops the work, cleans up its resources and settles it ascancelled. - A queued turn is cancelled immediately and returns
200. - A turn that has already finished returns
200with the result it settled with. Acompleted,failedorincompleteturn is never relabelledcancelled. - An idle run without
turn_idhas nothing to stop and returns200with its latest turn, unchanged.
An accepted cancellation is durable. Recording its events or notifying
the runtime can fail without rejecting the request; repeating it with the
same Idempotency-Key repeats those steps. A repeated request always
refers to the turn it first selected.
/runs/{runId}/cancelAuthorization
AuthorizationBearer <token>Path parameters
runIdstringrequired- pattern
"^run_[A-Za-z0-9]+$"
Headers
Idempotency-Keystringrequired- minLength
1- maxLength
255
Body
Additional properties are not allowed.
turn_idstring- pattern
"^turn_[A-Za-z0-9]+$"
Response
The selected turn was queued and is now cancelled, or it had already finished and is returned as it settled.
Additional properties are allowed.
idstringrequired- pattern
"^run_[A-Za-z0-9]+$"
objectstringrequired- const
"run"
agent_idstringrequired- pattern
"^agt_[A-Za-z0-9]+$"
agent_versionintegerrequiredThe deployment version that executes the returned turn. It equals turn.agent_version.
- minimum
1
statestringrequired- enum
["idle","busy"]
dispositionstringrequired- enum
["created_run","created_turn","queued_turn","steered"]
tagsarrayrequiredThe run's tags, sorted, without repeats. A run has at most 20.
- maxItems
20- uniqueItems
true
Show nested schema
A free-form label of 1 to 64 characters, stored exactly as sent. It is case-sensitive and nothing is trimmed. It may not be only whitespace or contain a control character.
- minLength
1- maxLength
64- pattern
"^(?![ \\u00a0\\u1680\\u2000-\\u200a\\u2028\\u2029\\u202f\\u205f\\u3000]+$)[^\\u0000-\\u001f\\u007f-\\u009f]+$"
turnobjectrequiredAdditional properties are allowed.
Show nested schema
idstringrequired- pattern
"^turn_[A-Za-z0-9]+$"
objectstringrequired- const
"turn"
agent_versionintegerrequiredThe deployment version of the agent that executes this turn. It is pinned when the turn is admitted and never changes, so it still names the version that ran after the agent's active version moves on. A run can hold turns on different versions.
- minimum
1
statusstringrequiredcompleted, failed, cancelled and incomplete are final.
completed returns its complete result and no error. failed
is described by error. cancelled has empty output and no
error. incomplete keeps the partial output it produced, and
error explains why it stopped when the runtime reported a reason
(otherwise null). cancelling means a cancellation
was accepted and the runtime is cleaning up.
- enum
["queued","in_progress","cancelling","completed","failed","cancelled","incomplete"]
inputarrayrequiredShow nested schema
Additional properties are allowed.
outputarrayrequiredShow nested schema
object1
Additional properties are allowed.
typestringrequired- const
"output_text"
textstringrequiredobject2
Additional properties are allowed.
typestringrequired- const
"output_file"
file_idstringrequiredfilenamestringrequiredmedia_typestringrequiredcreated_atintegerrequired- minimum
0
started_atinteger | nullrequired- minimum
0
completed_atinteger | nullrequired- minimum
0
duration_msinteger | nullrequired- minimum
0
errorunionrequiredWhy a failed turn stopped (always present), or why an incomplete turn stopped when the runtime reported a reason (otherwise null). null for every other status. It is stored with the turn and stays available regardless of event retention.
Show nested schema
null1
object2
The structured reason a turn stopped by error. code is a stable machine-readable reason and new codes can be added. retryable says whether sending the same work again can succeed. reference identifies the failure for support.
Additional properties are allowed.
codestringrequiredsourcestringrequired- enum
["provider","extension","runtime","platform","configuration"]
messagestringrequiredretryablebooleanrequiredreferencestringrequired