Add `/sandbox` to clai2: run a new conversation in an E2B, boxd, Daytona, OpenSandbox, Modal, Render, Sprites or Kubernetes sandbox, signed in to GitHub

Merged
AD
17d ago
+4321-20

Stack: #13587 E2B network → #13589 boxd secrets → #13590 Daytona secrets → #13591 OpenSandbox network_policy/credential_proxy → #13592 clai2 /sandbox.

Why we make these changes

/sandbox PROVIDER moves a new conversation into a cloud sandbox, so the agent works there instead of on the user's machine. It copies the checkout in (branch, unpushed commits, uncommitted files), and git (and gh, where the image has it) there act as the user's gh login.

The GitHub token reaches the sandbox in one of two ways, and the docs say which for each provider:

ProviderExtraGitHub tokenWho can use it
e2bpydantic-clai2[e2b]In the sandbox's network rules; the sandbox's GH_TOKEN is a stand-inAnyone with an API key for the E2B team
boxdpydantic-clai2[boxd]A private boxd secret made for the machine, deleted with itYou; note boxd may place it in a request body
daytonapydantic-clai2[daytona]A Daytona organization secret bound to the GitHub hosts, deleted with the sandbox; the sandbox holds a dtn_secret_… stand-inAnyone in the organization who can create sandboxes
opensandboxpydantic-clai2[opensandbox]The sandbox's credential vault in the egress sidecar's memory; the sandbox holds a stand-in. With a login, egress is GitHub's three hosts onlyYour OpenSandbox server's operators
modal, render, sprites, kubernetespydantic-clai2[modal|render|sprites|kubernetes]Written into two files in the sandbox's home (~/.config/clai/github-token, ~/.config/gh/hosts.yml, mode 600)Anything run in the sandbox

/sandbox now accepts harness backends that only run commands (OpenSandbox, Kubernetes): its file writes go through Workspace, which uses a backend's file API when it has one and shell commands otherwise. On Kubernetes that means the token travels base64-encoded inside a command sent to sandboxd; the docs say so.

New public surface

  • Harness: a failed Render create now includes Render's reason, such as a missing payment card.
  • clai2: a built-in plugin and the extras above.

User-visible behavior

/sandbox lists providers; /sandbox PROVIDER before the first prompt starts one; /sandbox delete deletes it (and the provider's copy of the token) and keeps the history; /new returns to this machine. A resumed conversation reopens its sandbox.

The conversation remembers its sandbox the way core picks a run's workspace: the latest ModelResponse.workspace_ref. /sandbox commits the user's command and an empty response naming the sandbox (providers send nothing for a response with no parts, so the model is not made to have said anything; the instructions tell it where its tools run). /compact adds the same empty response when compacting dropped every response naming a sandbox, which happened after a !command and would have moved the next turn back to this machine. Local folders are left alone, and nothing outside clai2 changes.

When a command needs another key, the agent calls request_env(name, reason); CLAI shows the /keys picker and adds the key to every later command in that sandbox, on every provider the same way (a WrapperWorkspace around the backend; no harness API). The value never reaches the model. It lasts while the conversation stays open in CLAI; after a restart the agent asks again and the user picks the saved entry. Docs: docs/reference.md "Cloud sandboxes: /sandbox".

Verification

  • tests/clai2/test_sandbox.py: seeding (including a backend that only runs commands), the command, the lifecycle (cancelled create, failed login or delete, rename), and every provider through the harness's own SDK fakes; no token in any argv or exec URL.
  • Live, real GitHub token, on E2B: git push and gh pr create worked; no token found in the sandbox.
  • Live, dummy GitHub token, through each provider:
    • boxd, Daytona, OpenSandbox (local server): GH_TOKEN is a stand-in, the dummy is found nowhere in the sandbox's env, and the proxy swaps it (httpbin basic-auth bound to the same credential: 200 with the stand-in, 401 with a wrong password). Delete removes the provider's secret or vault.
    • Modal, Render, Sprites, Kubernetes (kind + agent-sandbox v1.0.11, arm64): token file and hosts.yml hold the dummy at mode 600; git's credential helper returns it.
    • All: seeding a repo keeps HEAD and uncommitted files, reopen works, delete leaves nothing behind.
  • Live, end to end through a clai2 Session on 12afda885a, on E2B and on Modal (dummy GitHub token, dummy requested key): /sandbox saves an empty response naming the sandbox; a command before request_env sees no key and one after sees it; the key is nowhere in the history; after a !command-shaped request, /compact (summarization on a real model) adds the empty response back and the next turn runs in the sandbox with the key still set; real turns on anthropic:claude-sonnet-4-5 and openai:gpt-5 accept the history and run in the sandbox; /sandbox delete removes it. 12/12 checks on each.
  • /compact keeps the sandbox: TestCompaction in test_sandbox.py (summary and truncation, after a !command, a cancelled turn, or nothing; a failed or cancelled turn after compacting) and test_compaction.py (a local folder adds nothing). The !command cases fail without the fix.

Security note

On modal, render, sprites and kubernetes anything the agent runs can read the token. Pick a proxy provider when that matters. boxd may put the real token in a request body to GitHub.

Not included

The local sandboxes (Docker, boxlite, smol, bubblewrap).

What changes for existing users

Nothing until they run /sandbox.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.