Interrupt Task
Interrupt Task
/v2/tasks/{task_id}/interruptPass expected_generation from the input-list response and retain it across retries, including after a lost HTTP response. The same expected_generation and Stop endpoint preserve the original target without interrupting newer work. Omitting expected_generation selects the current generation on each request and can target newer work on a retry. Cancellation may already have occurred before an error response: queued inputs can be cancelled even when native cancellation is unconfirmed. An error does not roll back those cancellations or prove that the original execution is inactive. Task-wide Stop can cancel an older runner without host-turn support only after its exact physical run is recorded against the original live execution lease and sandbox. Retries use that recorded run; they never fall back to cancelling every active run. Turn-scoped Stop still requires host-turn support. HTTP 400 with detail.code=invalid_input_generation means expected_generation is ahead of the task's input stream. This invalid generation did not initiate cancellation. Read the current generation before making a valid Stop request. No Retry-After header is returned. This does not change the requirement to retain the original generation when retrying an unconfirmed Stop. HTTP 409 with detail.code=turn_interrupt_pending means the original execution is still starting or finalizing. Retain the same Stop request and expected_generation, and retry after one second as directed by Retry-After: 1. HTTP 409 with detail.code=task_recovery_required means the task is quarantined or retired. Messages are retained; operator recovery is required instead of automatic retries. Continue in detail.replacement_task_id when a non-null recovery task is returned. No Retry-After header is returned. HTTP 503 with detail.code=turn_interrupt_unconfirmed means cancellation or its durable acknowledgement could not be confirmed. A database failure can occur before or after queued inputs or the original execution were cancelled. Retain the same Stop request and expected_generation, and retry after one second as directed by Retry-After: 1. This is not a successful Stop acknowledgement. HTTP 503 with detail.code=turn_interrupt_recovery_required means the runtime needs operator recovery before more instructions can run, including when authority over the original execution has expired or been lost. Messages are retained. Wait for recovery instead of automatically retrying; no Retry-After header is returned. HTTP 422 with detail.code=turn_interrupt_unsupported means the runtime cannot safely interrupt the original execution. Do not automatically retry or fall back to cancelling a newer execution. If the original execution finishes, manually retry the same Stop request and expected_generation. If it still cannot be confirmed, use operator recovery or a compatible runtime. Request validation also returns HTTP 422, with an array in detail instead of an object with detail.code. HTTP 503 with a string detail means authorization is temporarily unavailable; there is no detail.code. Retry the same request after two seconds as directed by Retry-After: 2. Retain the same input_id for a follow-up, or expected_generation and endpoint for Stop.
Path Parameters
task_idstring · uuidrequiredRequest Body
expected_generationintegeroptionalcurl --request POST \
--url https://api.brainbaselabs.com/v2/tasks/{task_id}/interrupt \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"expected_generation": 0
}'{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"agent_id": "2b1e3b65-2c04-4fa2-a2d7-467901e98978",
"owner_user_id": "65139110-7c3c-4777-b692-80c218be3b9d",
"parent_task_id": "0595d3a2-39ad-4ab5-906d-3e39522e8eed",
"title": "string",
"status": "string",
"status_info": {},
"metadata": {
"property1": "string",
"property2": "string"
},
"sandbox_id": "string",
"machine_id": "76ca96f6-a9a8-43bf-917c-a176478a33ba",
"machine_size": "xs",
"benchmark_attempt_id": "5321abbd-5523-4e8e-9800-e8132608c1f0",
"created_at": "2019-08-24T14:15:22Z",
"generation": 0,
"cancelled_inputs": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"task_id": "736fde4d-9029-4915-8189-01353d6982cb",
"message_ids": [
"497f6eca-6276-4993-bfeb-53cbbbba6f08"
],
"status": "queued",
"turn_id": "2df5d97e-1e68-4315-ace5-61a464d94d93",
"generation": 0,
"sequence": 0,
"reason": "string",
"created_at": "2019-08-24T14:15:22Z",
"updated_at": "2019-08-24T14:15:22Z",
"messages": [
{
"id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
"task_id": "736fde4d-9029-4915-8189-01353d6982cb",
"role": "string",
"content": null,
"name": "string",
"tool_calls": {},
"tool_call_id": "string",
"metadata": {},
"created_at": "2019-08-24T14:15:22Z"
}
]
}
]
}