Skip to content

Rollouts

Fork a sandbox into branches, run one script in each, score them and keep the best.

Every method shows the same operation in each SDK; pick a language once and every tab on the site follows it.

Python TypeScript Go Ruby Java

A rollout as the API last reported it; refresh, wait and cancel update it.

Python exposes these as methods; see below.

Not in the Python SDK’s Rollout.

Not in the Python SDK’s Rollout.

branches: list[RolloutBranch]

Property (read-only).

def cancel(self) -> 'Rollout'

Stop the commands still running and kill every branch, kept ones included.

Returns 'Rollout'

Source: sdk/python/svm/rollouts.py:158

Not in the Python SDK’s Rollout.

done: bool

Property (read-only).

id: str

Property (read-only).

Not in the Python SDK’s Rollout.

Not in the Python SDK’s Rollout.

Not in the Python SDK’s Rollout.

Not in the Python SDK’s Rollout.

Not in the Python SDK’s Rollout.

Not in the Python SDK’s Rollout.

def kept_sandboxes(self) -> list['Sandbox']

Connect to the kept branches, best reward first.

Returns list['Sandbox']

Source: sdk/python/svm/rollouts.py:163
def refresh(self) -> 'Rollout'

Returns 'Rollout'

Source: sdk/python/svm/rollouts.py:145
rewards: list[float | None]

Property (read-only).

Each branch’s reward, in index order.

state: str

Property (read-only).

summary: dict[str, Any]

Property (read-only).

Not in the Python SDK’s Rollout.

Not in the Python SDK’s Rollout.

Not in the Python SDK’s Rollout.

Not in the Python SDK’s Rollout.

def wait(self, timeout: float=1800.0, poll: float=1.0) -> 'Rollout'

Read the rollout until it is no longer running, at most timeout seconds.

Parameter Type Default
timeout float 1800.0
poll float 1.0

Returns 'Rollout'

Raises TimeoutError

Source: sdk/python/svm/rollouts.py:149

Not in the Python SDK’s Rollout.

Python TypeScript Go Ruby Java

One branch: its sandbox, what its command did and its reward. kept branches are still running.

Property Type Description
duration_ms int
exit_code int | None
failure str
index int
kept bool
reward float | None
sandbox_id str
state str
stderr str
stdout str
timed_out bool
truncated bool
verifier_error str
Python TypeScript Go Ruby Java

Rollouts (API-020): fan a running sandbox out into N branches, run one command in each, score it, keep the best.

rollouts.create(base, n, command=... or script=..., verifier=...) forks base (a Sandbox or its id) into n branches with the direct fork (memory, disk and running processes), runs the command in every branch at once and scores each with the verifier. Branches the keep policy discards are killed within 10 s of being scored; kept ones stay running. By default the call waits for every branch and returns the finished Rollout::

from svm import Sandbox, rollouts

base = Sandbox.create(template=“swe-task”) run = rollouts.create(base, 64, script=“pytest -q tests/”, verifier=rollouts.verify_command([“/usr/local/bin/grade”]), keep=rollouts.keep_top_k(4)) for b in run.branches: print(b.index, b.exit_code, b.reward) best = run.kept_sandboxes()[0]

Every process sees SVM_ROLLOUT_ID and SVM_BRANCH_INDEX. A command or script verifier also sees SVM_EXIT_CODE and the command’s stdout on its stdin (a script verifier has it in $SVM_STDOUT as well); the last line it prints is the reward.

def create(base: 'Sandbox | str', n: int, *, command: Sequence[str] | None=None, script: str | None=None, verifier: dict[str, Any] | None=None, keep: dict[str, Any] | None=None, env: dict[str, str] | None=None, working_directory: str | None=None, user: str | None=None, timeout_seconds: int | None=None, sandbox_timeout_seconds: int | None=None, metadata: dict[str, str] | None=None, wait: bool=True, wait_timeout: float=1800.0, idempotency_key: str | None=None, client: 'SandboxClient | None'=None, request_timeout: float | None=300.0) -> Rollout
static

Fan base out into n branches, run command (argv, never through a shell, so argv[0] must be an absolute path in the guest such as /usr/bin/python3) or script (/bin/sh) in each and score it with verifier (default: exit status 0 scores 1). keep picks the branches that stay running (default: reward >= 1). With wait (the default) it returns once every branch is scored; otherwise at once, with the rollout running.

Parameter Type Default
base 'Sandbox | str'
n int
command Sequence[str] | None None
script str | None None
verifier dict[str, Any] | None None
keep dict[str, Any] | None None
env dict[str, str] | None None
working_directory str | None None
user str | None None
timeout_seconds int | None None
sandbox_timeout_seconds int | None None
metadata dict[str, str] | None None
wait bool True
wait_timeout float 1800.0
idempotency_key str | None None
client 'SandboxClient | None' None
request_timeout float | None 300.0

Returns Rollout

Source: sdk/python/svm/rollouts.py:181
def get(rollout_id: str, *, client: 'SandboxClient | None'=None) -> Rollout
static
Parameter Type Default
rollout_id str
client 'SandboxClient | None' None

Returns Rollout

Source: sdk/python/svm/rollouts.py:207
def keep_all() -> dict[str, Any]
static

Returns dict[str, Any]

Source: sdk/python/svm/rollouts.py:76
def keep_none() -> dict[str, Any]
static

Returns dict[str, Any]

Source: sdk/python/svm/rollouts.py:80
def keep_passed(min_reward: float=1.0) -> dict[str, Any]
static

Keep branches whose reward is at least min_reward (the default policy).

Parameter Type Default
min_reward float 1.0

Returns dict[str, Any]

Source: sdk/python/svm/rollouts.py:66
def keep_top_k(k: int) -> dict[str, Any]
static

Keep the k best rewards (ties go to the lower index).

Parameter Type Default
k int

Returns dict[str, Any]

Source: sdk/python/svm/rollouts.py:71
def verify_command(argv: Sequence[str], *, timeout_seconds: int | None=None) -> dict[str, Any]
static

Run argv in the branch after the command; the last line it prints is the reward. It reads the command’s stdout on its stdin and its exit code in $SVM_EXIT_CODE.

Parameter Type Default
argv Sequence[str]
timeout_seconds int | None None

Returns dict[str, Any]

Source: sdk/python/svm/rollouts.py:48
def verify_exit_code() -> dict[str, Any]
static

Reward 1 for exit status 0, else 0 (the default verifier).

Returns dict[str, Any]

Source: sdk/python/svm/rollouts.py:38
def verify_output_match(pattern: str) -> dict[str, Any]
static

Reward 1 when the RE2 pattern matches the command’s stdout, else 0.

Parameter Type Default
pattern str

Returns dict[str, Any]

Source: sdk/python/svm/rollouts.py:43
def verify_script(body: str, *, timeout_seconds: int | None=None) -> dict[str, Any]
static

Run body with /bin/sh in the branch after the command; the last line it prints is the reward. The script reads the command’s stdout on its stdin and in $SVM_STDOUT, and its exit code in $SVM_EXIT_CODE.

Parameter Type Default
body str
timeout_seconds int | None None

Returns dict[str, Any]

Source: sdk/python/svm/rollouts.py:57