Skip to content

Give one task to the agents of several copies of a running sandbox

POST
/sandboxes/{id}/races
curl --request POST \
--url https://api.global.stillbox.example/v1/sandboxes/ws-7k2m9q4x8w3z5r6t/races \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "task": "example", "racers": 1, "check": "example", "dir": "example", "minutes": 30 }'

Copies the sandbox racers times, memory included, and gives each copy’s agent task as a new conversation. When a copy’s agent finishes, the race summarises the files it changed in dir (with git) and runs check there, if given. Keep the best attempt with POST /races/{race_id}/keep; the other copies are deleted. The organization’s owners turn races on and set how many racers a race may have (ADR 0025): every racer uses its own tokens. A racer still working at the time limit is stopped (ADR 0031).

id
required
string
Media typeapplication/json
object
task
required

What every racer’s agent is asked to do.

string
>= 1 characters <= 32768 characters
racers

How many copies race; at most the organization’s race_max. Defaults to 3, or race_max if lower.

integer
>= 2 <= 10
check

A shell command run in dir in each copy after its agent finishes, such as npm test. Exit code 0 passes.

string
<= 4096 characters
dir

Where the check and the summary of changed files run. Defaults to the repository’s folder for a sandbox opened from a repository link, otherwise the agent’s home folder.

string
minutes

The time limit; racers still working then are stopped.

integer
default: 30 >= 1 <= 240

The race, with its racers starting

Media typeapplication/json
object
id
required
string
sandbox_id
required

The sandbox that was copied.

string
task
required
string
check
string
dir
required
string
state
required
string
Allowed values: running finished kept cancelled
winner_id

The kept copy.

string
deadline
required
string format: date-time
created_at
required
string format: date-time
finished_at
string format: date-time
by

The person who started the race.

string
racers
required
Array<object>
object
n
required

The racer’s number, from 1.

integer
sandbox_id
required
string
sandbox_name
required
string
sandbox_deleted
boolean
state
required

Starting until its copy runs; working while its agent works; checking while the check runs.

string
Allowed values: starting working checking done failed
response_id

The agent’s response in the copy; read it through /sandboxes/{id}/agent/v1/responses/{response_id}.

string
turn_status

How the agent’s turn ended (completed, failed or cancelled).

string
started_at
string format: date-time
finished_at
string format: date-time
duration_ms

How long the agent worked, once it reported its run.

integer format: int64
input_tokens
required
integer format: int64
output_tokens
required
integer format: int64
cost_usd
required

As the agent reported it.

number format: double
changes
required

Git’s summary of the files changed in dir, untracked files included; empty without changes or git.

string
check_exit_code

The check’s exit code; absent without a check.

integer
check_output
required

The last 4 KB of the check’s output.

string
error
string

Example

{
"state": "running",
"racers": [
{
"state": "starting"
}
]
}

The request is invalid

Media typeapplication/json
object
code
required
string
message
required
string

Example

{
"code": "not_found"
}

The API key is missing or invalid

Media typeapplication/json
object
code
required
string
message
required
string

Example

{
"code": "not_found"
}

Only an owner can do this (owner_only), or the invitation is for another address (not_invited)

Media typeapplication/json
object
code
required
string
message
required
string

Example

{
"code": "not_found"
}

No such sandbox in your organization (or no such file)

Media typeapplication/json
object
code
required
string
message
required
string

Example

{
"code": "not_found"
}

The sandbox isn’t running, or its server is unreachable right now

Media typeapplication/json
object
code
required
string
message
required
string

Example

{
"code": "not_found"
}