Skip to content

Worker fail callback

POST
/internal/computer-use/{session_id}/fail
curl --request POST \
--url https://api.ultimateteam.ai/internal/computer-use/2489E9AD-2EE2-8E00-8EC9-32D5F69181C0/fail \
--header 'Content-Type: application/json' \
--header 'X-API-Key: <X-API-Key>' \
--data '{ "error": "example", "steps_executed": 0, "tenant_id": "2489E9AD-2EE2-8E00-8EC9-32D5F69181C0", "usage": { "cache_creation_input_tokens": 1, "cache_read_input_tokens": 1, "input_tokens": 1, "model": "example", "output_tokens": 1, "turns": 1 } }'

Called by the Cloud Run container on failure; settles actual provider usage without charging the completion fee.

session_id
required
Session Id
string format: uuid
Media typeapplication/json
FailCallbackBody

Request body for the worker fail callback.

Attributes: error: Error message from the container. tenant_id: Tenant UUID (passed by container for routing). steps_executed: Iterations completed before the failure. usage: Accumulated LLM token usage. A failed run still burned every token it burned before failing, so this is carried on the failure path too and is NOT refunded.

object
error
required
Error
string
steps_executed
Steps Executed
integer
0
tenant_id
required
Tenant Id
string format: uuid
usage
Any of:
ComputerUseUsageBody

Accumulated Anthropic token usage reported by the container.

The worker cannot bill from inside its isolated Cloud Run container (no Redis, no Postgres, no CreditManager – same isolation as the D-13 deviation documented in src/workers/computer_use_worker.py), so it counts tokens across every turn of the computer-use loop and reports the totals here. ComputerUseExecutor._meter_llm_usage runs the reserve/settle against the tenant’s real balance on receipt.

Missing receipts remain unknown; required counters never default to zero.

Attributes: model: Model the container actually called (priced against this). input_tokens: Summed usage.input_tokens across all turns. output_tokens: Summed usage.output_tokens across all turns. cache_creation_input_tokens: Summed cache-write tokens. cache_read_input_tokens: Summed cache-read tokens. turns: Number of provider round-trips.

object
cache_creation_input_tokens
required
Cache Creation Input Tokens
integer
cache_read_input_tokens
required
Cache Read Input Tokens
integer
input_tokens
required
Input Tokens
integer
model
required
Model
string
output_tokens
required
Output Tokens
integer
turns
required
Turns
integer

Successful Response

Media typeapplication/json
Response Worker Fail Callback Internal Computer Use Session Id Fail Post
object
key
additional properties
string
Examplegenerated
{
"additionalProperty": "example"
}

Validation Error

Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
ctx
Context
object
input
Input
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
Examplegenerated
{
"detail": [
{
"ctx": {},
"input": "example",
"loc": [
"example"
],
"msg": "example",
"type": "example"
}
]
}