Give one task to the agents of several copies of a running sandbox
const url = 'https://api.global.stillbox.example/v1/sandboxes/ws-7k2m9q4x8w3z5r6t/races';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"task":"example","racers":1,"check":"example","dir":"example","minutes":30}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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).
Authorizations
Section titled “Authorizations”Parameters
Section titled “Parameters”Path Parameters
Section titled “Path Parameters”Request Bodyrequired
Section titled “Request Bodyrequired”object
What every racer’s agent is asked to do.
How many copies race; at most the organization’s race_max. Defaults to 3, or race_max if lower.
A shell command run in dir in each copy after its agent finishes, such as npm test. Exit code 0 passes.
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.
The time limit; racers still working then are stopped.
Responses
Section titled “Responses”The race, with its racers starting
object
The sandbox that was copied.
The kept copy.
The person who started the race.
object
The racer’s number, from 1.
Starting until its copy runs; working while its agent works; checking while the check runs.
The agent’s response in the copy; read it through /sandboxes/{id}/agent/v1/responses/{response_id}.
How the agent’s turn ended (completed, failed or cancelled).
How long the agent worked, once it reported its run.
As the agent reported it.
Git’s summary of the files changed in dir, untracked files included; empty without changes or git.
The check’s exit code; absent without a check.
The last 4 KB of the check’s output.
Example
{ "state": "running", "racers": [ { "state": "starting" } ]}The request is invalid
object
Example
{ "code": "not_found"}The API key is missing or invalid
object
Example
{ "code": "not_found"}Only an owner can do this (owner_only), or the invitation is for another address (not_invited)
object
Example
{ "code": "not_found"}No such sandbox in your organization (or no such file)
object
Example
{ "code": "not_found"}The sandbox isn’t running, or its server is unreachable right now
object
Example
{ "code": "not_found"}