kosa8 / Best sandboxes

Best sandbox · Reinforcement learning

The best sandbox for reinforcement learning environments

Updated

RL on agentic tasks needs thousands of identical copies of one environment, each sealed from the others, reset cheaply, scored by a grader the policy cannot see, and cleaned up when the trainer dies. kosa8 is built as the rollout platform for that: fork a prepared machine into live copies with memory and processes intact, run each rollout in its own microVM, and see every command the policy ran. Below is what runs today, the RL features on kosa8 Cloud, and the limits that apply.

01What an RL environment needs from a sandbox

In RL for coding or tool-use agents, the environment is a machine: a repository at a commit, its dependencies installed, maybe a database or a server running. The policy acts by running commands in it, and the reward comes from tests or a checker run afterwards.

That puts five demands on the sandbox. Reset has to be cheap, because it happens every episode. Copies have to be independent, so one episode cannot see or spoil another. The policy must not reach the answer: no network to fetch it, no access to the grader. A failed host must not look like a failed policy, or the trainer learns from noise. And a crashed trainer must not leave a thousand sandboxes running.

02Checklist for choosing one

  • Fast, faithful reset. Restore the prepared state, including running processes, not just a fresh image.
  • Fan-out from one state. Fork N live copies of a prepared environment, or create a batch at once.
  • Isolation between episodes. Separate kernels, disks and network rules per copy.
  • Closed network for rollouts. So a policy cannot download a solution.
  • A grader the policy cannot read. Run in a sealed copy after the rollout.
  • Failure classes. Infra errors marked as such, so the trainer masks them instead of scoring 0.
  • No leaks. Leases and a drain call, so sandboxes die with the trainer.
  • A record of actions and a view of the run. To investigate reward hacking and see cost as it goes.

03What kosa8 does today

Live on kosa8 Cloud and in the local engine now: fork (up to 1,000 live copies a call on kosa8 Cloud), snapshots that outlive their sandbox, a warm pool that hands out paused VMs, checkpoint and rewind inside an episode, egress deny, labels and TTLs, and the audit log of every command.

  • 74 msrestore a sandbox, median
  • 2.5 sfork 100 copies, 0 dead
  • 1.9 mscreate from the warm pool
  • 150held at once on one host

kosa8's own benchmark, 3 Nov 2026: Linux engine on one AMD Ryzen 7 7700 host (8 cores, 64 GB), 1 vCPU and 256 MiB sandboxes. One machine, not a guarantee. Method and how to reproduce: benchmarks.

Build the environment into a template once, so the sandboxes made from it need no network, then fork a prepared base per episode:

rollouts.py
from concurrent.futures import ThreadPoolExecutor
from kosa8 import Kosa8Client
 
client = Kosa8Client()
client.create_sandbox(name="env-base", template="click-env", egress="deny", mem_mb=2048)
client.shell("env-base", "cd /repo && python -m pytest -q -x")   # warm the shell session before forking
GRADER = open("hidden_tests.py").read()
 
def episode(sid, policy, max_steps=20):
    obs = client.shell(sid, "cd /repo && ls").stdout
    for _ in range(max_steps):
        command = policy(obs)              # your model picks the next command
        if command is None:
            break
        r = client.shell(sid, command, timeout_s=120)
        obs = r.stdout[-4000:] + r.stderr[-4000:]
    client.write_file(sid, "/workspace/.grader/test_hidden.py", GRADER)
    r = client.shell(sid, "cd /repo && python -m pytest -q /workspace/.grader", timeout_s=300)
    return 1.0 if r.ok else 0.0
 
forks = [f["id"] for f in client.fork("env-base", 8, prefix="ep-")["forks"]]
with ThreadPoolExecutor(len(forks)) as pool:
    rewards = list(pool.map(lambda sid: episode(sid, policy), forks))
for sid in forks:
    client.delete_sandbox(sid)

Forking snapshots the base once and restores it eight times; the base is never touched by a rollout. Within an episode, client.checkpoint(sid) and client.rewind(sid) let a search policy back out of a bad step. The same pattern runs on kosa8 Cloud with Kosa8Cloud; the rollout loop guide builds it step by step.

04The RL features on kosa8 Cloud

All of these are live on kosa8 Cloud (api.kosa8.com) and in the Python SDK, kosa8 0.5.4. The RL training guide has every call.

FeatureWhat it doesStatus
Batch createUp to 1,000 sandboxes in one call, paced across hosts by kosa8, with partial results instead of 429 storms.Live
Fork at scaleUp to 1,000 copies a call, with labels, a run id and a lease on every child, and partial results. One host holds the parent and 999 copies doing idle or light work (a fork of 999 took about 68 s), or about 700 to 770 copies that each write about 150 MiB of memory; past that, copies go to other hosts when there are any.Live
Leases, heartbeat, drainSandboxes die with the trainer; one call deletes a whole run.Live
Failure classesfailure_class and retryable on every answer (ok, exit_nonzero, timeout, oom, infra, quota, client), so infra errors are masked, not scored 0.Live
Sealed graderGrades in a fork with all egress denied and hidden files the solver never sees, and returns a reward (a grader runs at most 90 s).Live
RL runs dashboardReward by step, failures by class, live sandboxes against your limit, cost so far, a rollout table with a drawer per rollout, JSONL export, and recommended actions.Live
Python RL helpersAsyncCloud, kosa8.rl.Run and AsyncRun, lease(), map_rollouts, and adapters for Gymnasium, OpenEnv, verifiers, TRL and SWE-bench, in kosa8 0.5.4.Live
Hosted jobsHand kosa8 the tasks, a solver command and a grader; it runs every rollout, with retries, masking and a budget.Live

The quickstart, which runs as it is with pip install kosa8==0.5.4 and KOSA8_API_KEY set, and prints each rollout's reward:

quickstart.py
import asyncio
import random
 
import kosa8
from kosa8.rl import AsyncRun
 
# The hidden grader: it stays on your side until grading, then runs in a sealed
# fork with no network. Its last stdout line {"reward": x} is the reward.
GRADER = """
import json, sys
sys.path.insert(0, "/workspace")
try:
    from solution import add
    passed = sum(add(a, b) == a + b for a, b in [(1, 2), (-3, 3), (10, 5), (0, 0)])
except Exception:
    passed = 0
print(json.dumps({"reward": passed / 4, "metrics": {"passed": passed}}))
"""
 
tasks = [{"id": f"add-{i}", "prompt": "Write add(a, b) in /workspace/solution.py",
          "files": {"/grader/check.py": GRADER}} for i in range(4)]
 
def policy(prompt):                                # stand-in for your model
    op = random.choice(["+", "+", "-"])
    return f"def add(a, b):\n    return a {op} b\n"
 
async def solve(sbx, task):                        # the policy acts in its own copy
    await sbx.files.write("/workspace/solution.py", policy(task["prompt"]))
 
async def main():
    async with kosa8.AsyncCloud() as cloud:        # reads KOSA8_API_KEY
        # The run heartbeats its sandboxes and drains them when the block ends, even on a crash.
        async with AsyncRun(cloud, "grpo-demo", lease_s=600) as run:
            base = await cloud.sandboxes.create(template="python")
            results = await run.map(base, tasks, solve, group_size=2, concurrency=4,
                                    grade_cmd=["python3", "/grader/check.py"])
    print(results.rewards)                         # e.g. [1.0, 0.25, 1.0, 1.0, 0.25, 1.0, 1.0, 1.0]
    print(results.mean_reward, results.by_class)   # masked (infra) rollouts are None, left out of the mean
 
asyncio.run(main())

05Limits, plainly

PlanRunning at onceCloud sandbox-hours a monthLargest sandbox
Solo, $2921002 vCPU, 4 GB
Pro, $89105004 vCPU, 8 GB
Team, $169 a person255008 vCPU, 16 GB
Scale, $199 a person1,0001,00016 vCPU, 32 GB
  • Packs on any plan, monthly and stackable: +100 sandbox-hours for $15, +10 running at once for $49. Team and Scale hours are a person's, pooled; Scale runs up to 1,000 at once.
  • Fork makes at most 1,000 copies a call: about 1,000 light copies, or 700 to 770 heavy ones, fit on the parent's host, and the rest go to other hosts when there are any.
  • One region today: us-ash1 (Ashburn, Virginia, US East); on your own servers, wherever they are.
  • No GPUs on kosa8 Cloud. Keep the policy and trainer on your GPUs and run the environments on kosa8.
  • An exec answered in one response stops after 90 seconds; stream or background longer commands.

06What a run costs

Arithmetic from the published prices, nothing more. 10,000 rollouts of 3 minutes on the standard 2 vCPU sandbox are 30,000 sandbox-minutes: 500 sandbox-hours.

  • Pro, $89 a month: 500 sandbox-hours are included, so one such run uses the month's allowance; a second is 5 packs of +100, $75. At 10 running at once it takes about 50 hours end to end.
  • Scale, $199 a person a month: 1,000 sandbox-hours a person, room for two such runs. At 1,000 running at once it is 10 rounds of 3 minutes, about 30 minutes plus the time to make the sandboxes.
  • On 4 vCPU sandboxes the same run counts 1,000 sandbox-hours.

The figures leave out create and grading time, retries and whatever else the plan is used for.

07When another option fits better

  • Far more than 1,000 concurrent episodes. kosa8 Cloud runs up to 1,000 at once on Scale, in one region (US East). Fleets well past that may suit a provider built for them, or kosa8 on your own servers.
  • Pure-Python or simulated environments. If the environment is a Gymnasium simulation with no shell, you do not need a machine per episode; vectorised environments in one process are far cheaper.
  • GPU inside the environment. kosa8 Cloud has no GPUs, and a local kosa8 sandbox with a GPU cannot be checkpointed or forked, so those environments lose the fast reset.

08FAQ

How does kosa8 reset an RL environment?

By forking: fork restores live copies from one snapshot of the prepared base, with memory, processes and disk as they were, up to 1,000 a call on kosa8 Cloud. Delete a copy after its episode; the base is unchanged.

How do I stop the policy from reading the tests?

Use the sealed grader: POST /v1/sandboxes/{id}/grade runs the hidden tests in a fork with no network, so the solver sandbox never sees them. Keep the tests on your side until then.

How many environments can run at once?

On kosa8 Cloud your plan sets it: 2 on Solo, 10 on Pro, 25 on Team and up to 1,000 on Scale, plus 10 more for each $49 pack. Locally, as many as the machine's memory holds.

How do I keep infra failures out of the reward?

Every answer carries a failure_class and retryable; mask the infra and quota ones instead of scoring them 0. kosa8.rl does this for you: masked rollouts come back with reward None.

Has kosa8 published benchmarks?

For the engine, yes: restore in 74 ms median and a fork of 100 copies in 2.5 s on one 8-core host, on the benchmarks page. kosa8 has not published end-to-end RL throughput; measure it on your workload.

09Get started

Make an account (free Starter, no card; pick a plan when you need more), then run the loop above on kosa8 Cloud, or install kosa8 on a Mac, Linux or Windows (WSL2) machine.

10Sources

Related

Updated 2026-11-21