Skip to content

feat(sandbox): add a Mirage sandbox provider - #984

Open
zechengz wants to merge 5 commits into
scaleapi:mainfrom
zechengz:feat/mirage-sandbox
Open

zechengz wants to merge 5 commits into
scaleapi:mainfrom
zechengz:feat/mirage-sandbox

Conversation

@zechengz

@zechengz zechengz commented Dec 1, 2026 •

Copy link
Copy Markdown

Summary

Adds mirage, a built-in sandbox provider. Each deploy_sandbox step gets its own
Mirage workspace, a virtual terminal on a Mirage daemon, driven over the
daemon's HTTP API with httpx, so it needs no extra.

  • Config: url, an optional token, and an optional workspace table passed to Mirage as is (mounts, machines,
    env, command_limits).
  • A step's network policy becomes the workspace's allowlist, and its memory the workspace's max_memory.
  • A workspace serves no ports, so exposed_ports and containers are refused; envs and agents stay on another provider.
  • Programs such as python3 or docker run on the machines the workspace config names. The README's Examples show no
    machine, Mirage's in-process Monty, and a Docker container.

Testing

  • Unit tests against an in-memory daemon behind httpx.MockTransport, Mirage rows in the shared provider tests, and a
    smoke test gated on remote_sandbox.
  • Against Mirage's Python and TypeScript daemons and the mirage-ai 0.1.0 release, agent-env run hello --sandbox mirage and the smoke test pass.
  • With a local Docker container as the machine, six SWE-bench Verified trajectories replayed through agent-env with every
    recorded exit code matching.

Docs site

For the Sandboxes page, in the shape of kosa8's entry. A row after kosa8:

Provider A sandbox is Egress allowlist Needs
mirage a Mirage virtual terminal, a sandbox-like terminal environment yes a running Mirage daemon

A section after kosa8's:

Mirage

[sandbox.providers.mirage.config]
url = "http://127.0.0.1:8765"

It needs no extra, only a running Mirage daemon, and agent-env run hello --sandbox mirage checks the setup with no
model. Each deploy_sandbox step gets its own Mirage virtual terminal, which starts with KBs of memory instead of a
container or microVM. A workspace serves no ports, so envs and agents stay on another provider. The
mirage README
covers the rest.

Logos: /logos/mirage.svg, and /logos/mirage-dark.svg with fill: #FFFFFF; stroke: #000000;
<svg xmlns="http://www.w3.org/2000/svg" viewBox="8 8 144 144" width="144" height="144">
  <style>g { fill: #000000; stroke: #FFFFFF; }</style>
  <g stroke-width="2.5">
    <polygon points="19,45 80,10 80,45 50,63"/>
    <polygon points="80,10 141,45 110,63 80,45"/>
    <polygon points="141,45 141,115 110,98 110,63"/>
    <polygon points="141,115 80,150 80,115 110,98"/>
    <polygon points="80,150 19,115 50,98 80,115"/>
    <polygon points="19,115 19,45 50,63 50,98"/>
    <polygon points="80,45 110,63 110,98 80,115 50,98 50,63"/>
    <line x1="80" y1="80" x2="50" y2="63"/>
    <line x1="80" y1="80" x2="110" y2="63"/>
    <line x1="80" y1="80" x2="80" y2="115"/>
  </g>
</svg>

🤖 Generated with Claude Code

Confidence Score: 5/5RetriggerView in Greptile

The PR appears safe to merge, with all three previous findings addressed and no new actionable issues found.

Summary

Adds mirage as a built-in sandbox provider backed by a Mirage daemon.

  • A deploy_sandbox step can create a Mirage workspace.
  • Mirage sandboxes run commands and exchange files through the daemon.

Reviews (2) · Last reviewed commit: "fix(sandbox): bound the Mirage daemon ca..." · Reviewed by Greptile

zechengz and others added 4 commits December 1, 2026 11:54
A built-in `mirage` sandbox provider: each deploy_sandbox sandbox is a
workspace on a Mirage daemon (Python or TypeScript), driven over its HTTP
API with httpx, so it needs no extra. agent-env passes the user's Mirage
workspace config through and reads none of it; a step runs whatever that
workspace has. A workspace serves no ports, so envs and agents stay on
another provider.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…DME examples

- One error class, MirageError, as kosa8 and Agent37 have, carrying the code and errno from Mirage's error body.
  A missing workspace (not_found, no errno) is SandboxNotFoundError; a file call's ENOENT stays a MirageError.
  Connection errors are httpx's own.
- The workspace every sandbox starts from is built in __init__: the configured workspace, plus a RAM root (an exec
  mount, so an interpreter can run what a step loads) and lifted command limits where it sets none.
- Per-workspace calls share one path that maps a missing workspace; unused health call and fake fields removed.
- Imports at module top in the shared tests; the capability check joins the shared branch.
- README framed as Mirage virtual terminals, with Examples for the setups tested: no machine, Monty in process,
  and a Docker container as the compute through a machine mount.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- create_container: the base default calls create_vm with the container's port, which a Mirage workspace refuses
  before anything is made ("serves no ports, so it can't expose [port]").
- setup_vm_for_gateway: the base default waits for the VM and opens only the exposed ports, which a workspace has none of.
- MirageApi takes its url from the provider, with no default of its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- The default daemon URL is the provider's url default; the client's timeout and the lost answer's -1 sit where they
  are used.
- MirageError reads Mirage's error body itself, with no separate parser.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cancelled create

- Every daemon call has a 60 s timeout, so a delete that gets no answer can't hold terminate or a failed create's
  cleanup; only a shell line waits for its answer with no read timeout.
- The workspace id's suffix length is named, as agent37 names it.
- Tests: a create cancelled while the daemon answers deletes the workspace it made, and only a line has no read timeout.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant