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.
Rollout
Section titled “Rollout”A rollout as the API last reported it; refresh, wait and cancel update it.
Properties
Section titled “Properties”Python exposes these as methods; see below.
| Property | Type | Description |
|---|---|---|
client |
SandboxClient |
Go exposes these as methods; see below.
Ruby exposes these as methods; see below.
Java exposes these as methods; see below.
create()
Section titled “create()”Not in the Python SDK’s Rollout.
Not in the TypeScript SDK’s Rollout.
Not in the Go SDK’s Rollout.
def self.create(client, base_id, count, command: nil, script: nil, verifier: nil, keep: nil, env: nil, working_directory: nil, user: nil, timeout_seconds: nil, sandbox_timeout_seconds: nil, metadata: nil, idempotency_key: nil, wait: true, poll: 1.0)Starts a rollout of count branches of base_id; waits for it to finish unless wait is false. Pass exactly one of command and script. command is an argv whose argv[0] is an absolute path in the guest (it is not run through a shell, so “python3” alone fails; use “/usr/bin/python3” or a script). metadata tags the branch sandboxes.
| Parameter | Type | Default |
|---|---|---|
client |
||
base_id |
||
count |
||
command |
nil |
|
script |
nil |
|
verifier |
nil |
|
keep |
nil |
|
env |
nil |
|
working_directory |
nil |
|
user |
nil |
|
timeout_seconds |
nil |
|
sandbox_timeout_seconds |
nil |
|
metadata |
nil |
|
idempotency_key |
nil |
|
wait |
true |
|
poll |
1.0 |
sdk/ruby/lib/svm/rollouts.rb:42public static Rollout create(Client client, String baseId, int count, Options o)Starts a rollout of count branches of baseId; waits for it to finish unless o.wait is false.
| Parameter | Type | Default |
|---|---|---|
client |
Client |
|
baseId |
String |
|
count |
int |
|
o |
Options |
Returns Rollout
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:66Not in the Python SDK’s Rollout.
Not in the TypeScript SDK’s Rollout.
Not in the Go SDK’s Rollout.
def self.get(client, rollout_id)A handle to an existing rollout.
| Parameter | Type | Default |
|---|---|---|
client |
||
rollout_id |
sdk/ruby/lib/svm/rollouts.rb:54public static Rollout get(Client client, String rolloutId)A handle to an existing rollout.
| Parameter | Type | Default |
|---|---|---|
client |
Client |
|
rolloutId |
String |
Returns Rollout
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:77branches()
Section titled “branches()”branches: list[RolloutBranch]Property (read-only).
branches: RolloutBranch[]Property (read-only).
Not in the Go SDK’s Rollout.
def branchessdk/ruby/lib/svm/rollouts.rb:37public List<Map<String, Object>> branches()Returns List<Map<String, Object>>
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:62cancel()
Section titled “cancel()”def cancel(self) -> 'Rollout'Stop the commands still running and kill every branch, kept ones included.
Returns 'Rollout'
sdk/python/svm/rollouts.py:158async cancel(): Promise<Rollout>Stop the commands still running and kill every branch, kept ones included.
Returns Promise<Rollout>
sdk/typescript/src/rollouts.ts:114func (r *Rollout) Cancel(ctx context.Context) errorCancel stops the commands still running and kills every branch, kept ones included.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
Returns error
sdk/go/rollouts.go:260def cancelsdk/ruby/lib/svm/rollouts.rb:76public Rollout cancel()Returns Rollout
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:96constructor()
Section titled “constructor()”Not in the Python SDK’s Rollout.
constructor(readonly client: SandboxClient, public info: RolloutInfo)| Parameter | Type | Default |
|---|---|---|
client |
SandboxClient |
|
info |
RolloutInfo |
sdk/typescript/src/rollouts.ts:87Not in the Go SDK’s Rollout.
Not in the Ruby SDK’s Rollout.
Not in the Java SDK’s Rollout.
done()
Section titled “done()”done: boolProperty (read-only).
done: booleanProperty (read-only).
Not in the Go SDK’s Rollout.
def done?sdk/ruby/lib/svm/rollouts.rb:34public boolean done()Returns boolean
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:56id: strProperty (read-only).
id: stringProperty (read-only).
Not in the Go SDK’s Rollout.
def idsdk/ruby/lib/svm/rollouts.rb:32public String id()Returns String
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:53info()
Section titled “info()”Not in the Python SDK’s Rollout.
info: RolloutInfoProperty.
Info: RolloutInfoProperty.
infoProperty (read-only).
public Map<String, Object> info()Returns Map<String, Object>
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:52initialize()
Section titled “initialize()”Not in the Python SDK’s Rollout.
Not in the TypeScript SDK’s Rollout.
Not in the Go SDK’s Rollout.
def initialize(client, info)| Parameter | Type | Default |
|---|---|---|
client |
||
info |
sdk/ruby/lib/svm/rollouts.rb:28Not in the Java SDK’s Rollout.
keep_all()
Section titled “keep_all()”Not in the Python SDK’s Rollout.
Not in the TypeScript SDK’s Rollout.
Not in the Go SDK’s Rollout.
Not in the Ruby SDK’s Rollout.
public static Map<String, Object> keepAll()Returns Map<String, Object>
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:38keep_none()
Section titled “keep_none()”Not in the Python SDK’s Rollout.
Not in the TypeScript SDK’s Rollout.
Not in the Go SDK’s Rollout.
Not in the Ruby SDK’s Rollout.
public static Map<String, Object> keepNone()Returns Map<String, Object>
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:39keep_passed()
Section titled “keep_passed()”Not in the Python SDK’s Rollout.
Not in the TypeScript SDK’s Rollout.
Not in the Go SDK’s Rollout.
Not in the Ruby SDK’s Rollout.
public static Map<String, Object> keepPassed(double minReward)| Parameter | Type | Default |
|---|---|---|
minReward |
double |
Returns Map<String, Object>
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:36keep_top_k()
Section titled “keep_top_k()”Not in the Python SDK’s Rollout.
Not in the TypeScript SDK’s Rollout.
Not in the Go SDK’s Rollout.
Not in the Ruby SDK’s Rollout.
public static Map<String, Object> keepTopK(int k)| Parameter | Type | Default |
|---|---|---|
k |
int |
Returns Map<String, Object>
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:37kept_sandboxes()
Section titled “kept_sandboxes()”def kept_sandboxes(self) -> list['Sandbox']Connect to the kept branches, best reward first.
Returns list['Sandbox']
sdk/python/svm/rollouts.py:163keptSandboxes(): Promise<Sandbox[]>Connect to the kept branches, best reward first.
Returns Promise<Sandbox[]>
sdk/typescript/src/rollouts.ts:120func (r *Rollout) KeptSandboxes(ctx context.Context) ([]*Sandbox, error)KeptSandboxes connects to the kept branches, best reward first.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
Returns ([]*Sandbox, error)
sdk/go/rollouts.go:282def kept_sandboxesThe kept branches as connected sandboxes, best reward first.
Source:sdk/ruby/lib/svm/rollouts.rb:85public List<Sandbox> keptSandboxes()The kept branches as connected sandboxes, best reward first.
Returns List<Sandbox>
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:106refresh()
Section titled “refresh()”def refresh(self) -> 'Rollout'Returns 'Rollout'
sdk/python/svm/rollouts.py:145async refresh(): Promise<Rollout>Returns Promise<Rollout>
sdk/typescript/src/rollouts.ts:98func (r *Rollout) Refresh(ctx context.Context) errorRefresh reads the rollout again.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
Returns error
sdk/go/rollouts.go:227def refreshsdk/ruby/lib/svm/rollouts.rb:60public Rollout refresh()Returns Rollout
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:83rewards()
Section titled “rewards()”rewards: list[float | None]Property (read-only).
Each branch’s reward, in index order.
rewards: Array<number | null>Property (read-only).
Each branch’s reward, in index order.
func (r *Rollout) Rewards() []*float64Rewards are each branch’s reward, in index order (nil where it has none).
Returns []*float64
sdk/go/rollouts.go:273def rewardsThe reward of each branch, nil where the verifier gave none.
Source:sdk/ruby/lib/svm/rollouts.rb:82public List<Double> rewards()The reward of each branch, null where the verifier gave none.
Returns List<Double>
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:99state()
Section titled “state()”state: strProperty (read-only).
state: RolloutInfo["state"]Property (read-only).
func (r *Rollout) State() stringState is the rollout’s state as last read: running, completed, failed or cancelled.
Returns string
sdk/go/rollouts.go:221def statesdk/ruby/lib/svm/rollouts.rb:33public String state()running, completed, failed or cancelled.
Returns String
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:55summary()
Section titled “summary()”summary: dict[str, Any]Property (read-only).
summary: Partial<RolloutSummary>Property (read-only).
The totals (finished, kept, released, mean and max reward, best sandbox); empty until the API reports them.
func (r *Rollout) Summary() RolloutSummarySummary is what the branches add up to, as last read.
Returns RolloutSummary
sdk/go/rollouts.go:224def summaryThe counts the server keeps for the rollout ({} until it has them).
Source:sdk/ruby/lib/svm/rollouts.rb:36public Map<String, Object> summary()The rollout’s summary (finished, kept, released, mean_reward, max_reward, best_sandbox_id); empty until the API reports one.
Returns Map<String, Object>
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:59verify_command()
Section titled “verify_command()”Not in the Python SDK’s Rollout.
Not in the TypeScript SDK’s Rollout.
Not in the Go SDK’s Rollout.
Not in the Ruby SDK’s Rollout.
public static Map<String, Object> verifyCommand(List<String> argv)public static Map<String, Object> verifyCommand(List<String> argv, Integer timeoutSeconds)Runs argv (argv[0] absolute) in the branch after the command; the last line it prints is the reward. It reads the command’s stdout on its stdin.
| Parameter | Type | Default |
|---|---|---|
argv |
List<String> |
|
timeoutSeconds |
Integer |
optional |
Returns Map<String, Object>
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:26verify_exit_code()
Section titled “verify_exit_code()”Not in the Python SDK’s Rollout.
Not in the TypeScript SDK’s Rollout.
Not in the Go SDK’s Rollout.
Not in the Ruby SDK’s Rollout.
public static Map<String, Object> verifyExitCode()Returns Map<String, Object>
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:23verify_output_match()
Section titled “verify_output_match()”Not in the Python SDK’s Rollout.
Not in the TypeScript SDK’s Rollout.
Not in the Go SDK’s Rollout.
Not in the Ruby SDK’s Rollout.
public static Map<String, Object> verifyOutputMatch(String pattern)| Parameter | Type | Default |
|---|---|---|
pattern |
String |
Returns Map<String, Object>
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:24verify_script()
Section titled “verify_script()”Not in the Python SDK’s Rollout.
Not in the TypeScript SDK’s Rollout.
Not in the Go SDK’s Rollout.
Not in the Ruby SDK’s Rollout.
public static Map<String, Object> verifyScript(String body)public static Map<String, Object> verifyScript(String body, Integer timeoutSeconds)Runs 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 |
String |
|
timeoutSeconds |
Integer |
optional |
Returns Map<String, Object>
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:33wait()
Section titled “wait()”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
sdk/python/svm/rollouts.py:149async wait(timeoutMs = 1_800_000, pollMs = 1000): Promise<Rollout>Read the rollout until it is no longer running.
| Parameter | Type | Default |
|---|---|---|
timeoutMs |
number |
1_800_000 |
pollMs |
number |
1000 |
Returns Promise<Rollout>
Raises TimeoutError
sdk/typescript/src/rollouts.ts:104func (r *Rollout) Wait(ctx context.Context, poll time.Duration) errorWait reads the rollout every poll (1 s when zero) until it is no longer running or ctx ends.
| Parameter | Type | Default |
|---|---|---|
ctx |
context.Context |
|
poll |
time.Duration |
Returns error
sdk/go/rollouts.go:240def wait(poll: 1.0, timeout: nil)Polls until the rollout is no longer running.
| Parameter | Type | Default |
|---|---|---|
poll |
1.0 |
|
timeout |
nil |
Raises TimeoutError
sdk/ruby/lib/svm/rollouts.rb:66Not in the Java SDK’s Rollout.
wait_done()
Section titled “wait_done()”Not in the Python SDK’s Rollout.
Not in the TypeScript SDK’s Rollout.
Not in the Go SDK’s Rollout.
Not in the Ruby SDK’s Rollout.
public Rollout waitDone(double pollSeconds, double timeoutSeconds)Polls until the rollout is no longer running; timeoutSeconds 0 waits for ever.
| Parameter | Type | Default |
|---|---|---|
pollSeconds |
double |
|
timeoutSeconds |
double |
Returns Rollout
Raises TimeoutException
sdk/java/src/main/java/dev/svm/sandbox/Rollout.java:86RolloutBranch
Section titled “RolloutBranch”One branch: its sandbox, what its command did and its reward. kept branches are still running.
Properties
Section titled “Properties”| 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 |
| Property | Type | Description |
|---|---|---|
duration_ms |
number |
|
exit_code |
number | null |
|
failure |
string |
|
finished_at |
string |
|
index |
number |
|
kept |
boolean |
|
released_at |
string |
|
reward |
number | null |
|
sandbox_id |
string |
|
state |
"running" | "completed" | "failed" | "cancelled" |
|
stderr |
string |
|
stdout |
string |
|
timed_out |
boolean |
|
truncated |
boolean |
|
verifier_error |
string |
| Property | Type | Description |
|---|---|---|
DurationMS |
int64 |
|
ExitCode |
*int64 |
|
Failure |
string |
|
FinishedAt |
string |
|
Index |
int |
|
Kept |
bool |
|
ReleasedAt |
string |
|
Reward |
*float64 |
|
SandboxID |
string |
|
State |
string |
|
Stderr |
string |
|
Stdout |
string |
|
TimedOut |
bool |
|
Truncated |
bool |
|
VerifierError |
string |
Not in the Ruby SDK.
Not in the Java SDK.
rollouts
Section titled “rollouts”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.
create()
Section titled “create()”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) -> RolloutFan 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
sdk/python/svm/rollouts.py:181async function create(base: Sandbox | string, n: number, options: CreateRolloutOptions): Promise<Rollout>Fan base out into n branches, run command (argv) 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).
| Parameter | Type | Default |
|---|---|---|
base |
Sandbox | string |
|
n |
number |
|
options |
CreateRolloutOptions |
Returns Promise<Rollout>
sdk/typescript/src/rollouts.ts:128Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
def get(rollout_id: str, *, client: 'SandboxClient | None'=None) -> Rollout| Parameter | Type | Default |
|---|---|---|
rollout_id |
str |
|
client |
'SandboxClient | None' |
None |
Returns Rollout
sdk/python/svm/rollouts.py:207async function get(rolloutId: string, client: SandboxClient = new SandboxClient()): Promise<Rollout>| Parameter | Type | Default |
|---|---|---|
rolloutId |
string |
|
client |
SandboxClient |
new SandboxClient() |
Returns Promise<Rollout>
sdk/typescript/src/rollouts.ts:144Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
keep_all()
Section titled “keep_all()”def keep_all() -> dict[str, Any]Returns dict[str, Any]
sdk/python/svm/rollouts.py:76Not in the TypeScript SDK’s rollouts.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
keep_none()
Section titled “keep_none()”def keep_none() -> dict[str, Any]Returns dict[str, Any]
sdk/python/svm/rollouts.py:80Not in the TypeScript SDK’s rollouts.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
keep_passed()
Section titled “keep_passed()”def keep_passed(min_reward: float=1.0) -> dict[str, Any]Keep branches whose reward is at least min_reward (the default policy).
| Parameter | Type | Default |
|---|---|---|
min_reward |
float |
1.0 |
Returns dict[str, Any]
sdk/python/svm/rollouts.py:66Not in the TypeScript SDK’s rollouts.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
keep_top_k()
Section titled “keep_top_k()”def keep_top_k(k: int) -> dict[str, Any]Keep the k best rewards (ties go to the lower index).
| Parameter | Type | Default |
|---|---|---|
k |
int |
Returns dict[str, Any]
sdk/python/svm/rollouts.py:71Not in the TypeScript SDK’s rollouts.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
verify_command()
Section titled “verify_command()”def verify_command(argv: Sequence[str], *, timeout_seconds: int | None=None) -> dict[str, Any]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]
sdk/python/svm/rollouts.py:48Not in the TypeScript SDK’s rollouts.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
verify_exit_code()
Section titled “verify_exit_code()”def verify_exit_code() -> dict[str, Any]Reward 1 for exit status 0, else 0 (the default verifier).
Returns dict[str, Any]
sdk/python/svm/rollouts.py:38Not in the TypeScript SDK’s rollouts.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
verify_output_match()
Section titled “verify_output_match()”def verify_output_match(pattern: str) -> dict[str, Any]Reward 1 when the RE2 pattern matches the command’s stdout, else 0.
| Parameter | Type | Default |
|---|---|---|
pattern |
str |
Returns dict[str, Any]
sdk/python/svm/rollouts.py:43Not in the TypeScript SDK’s rollouts.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.
verify_script()
Section titled “verify_script()”def verify_script(body: str, *, timeout_seconds: int | None=None) -> dict[str, Any]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]
sdk/python/svm/rollouts.py:57Not in the TypeScript SDK’s rollouts.
Not in the Go SDK.
Not in the Ruby SDK.
Not in the Java SDK.