kosa8 / Guides

Guide · OpenCode and Amp

How do I run OpenCode or Amp in a sandbox?

Updated

For OpenCode, use kosa8's built-in kit: kosa8 agent run opencode installs a pinned OpenCode in a microVM that sees only your project folder, and brokers your Anthropic or OpenAI key so the sandbox holds a placeholder instead. For Amp there is no built-in kit; register kosa8 with Amp through MCP (kosa8 mcp install amp) so the commands it runs go to sealed sandboxes, while Amp itself stays on your machine.

01Steps

  1. Install kosa8 and sign in. It runs on an Apple silicon Mac, x86-64 Linux, or Windows through WSL2.

  2. Put your model key in your own shell. The opencode kit brokers ANTHROPIC_API_KEY and OPENAI_API_KEY: kosa8 reads the key when the run starts and gives it to a broker on your machine, which adds it to requests for that provider only.

  3. See what the run would do. The plan shows the folder shared at /work, the hosts allowed and which keys are brokered.

  4. Commit, then start OpenCode. The agent can change anything in the shared folder, so commit first.

  5. Or run one task headless. Arguments after the kit's name go to OpenCode; opencode run takes a prompt and exits.

  6. Review the result. The sandbox is removed when OpenCode exits; your folder keeps the changes.

  7. For Amp, give it kosa8 as an MCP server. This writes kosa8 into ~/.config/amp/settings.json (keeping your other servers, and saving the old file as .bak) and installs the kosa8 skill, which tells the agent to run installs, builds and untrusted code in a sandbox. Start the daemon first, then restart Amp.

02What the Amp setup does and does not contain

With MCP, Amp keeps running on your machine with your files; what changes is that it now has tools such as sandbox_create, sandbox_shell, sandbox_checkpoint and sandbox_rewind, and the skill tells it to use them for risky work. A sandbox it creates has no network unless it asks for specific hosts.

That contains the commands Amp chooses to send to a sandbox, not Amp itself. kosa8 does not ship an Amp kit; a kit of your own is possible (see Writing a kit), but kosa8 has not tested Amp in one.

03What the OpenCode sandbox enforces

  • Files. Only the -w folder, at /work.
  • Keys. Brokered: the sandbox holds a placeholder, and the broker on your machine adds the real key for the model provider only.
  • Network. Closed except through the broker and the hosts the kit lists (registry.npmjs.org). Refused attempts are in the audit log.
  • Software. OpenCode is installed at a pinned version, its download checked against a digest first.

04Other options

  • A container. Running OpenCode or Amp in Docker with only the project mounted is a reasonable boundary for trusted work; it shares the host kernel and holds the real key.
  • A local model. To keep prompts on your machine as well, serve a model with kosa8 model serve and point OpenCode at it as an OpenAI-compatible provider; see the local model guide.
  • Amp's own controls. Amp's permission settings decide which tools run without asking; they are rules inside the agent, not a boundary around it.

05FAQ

Does OpenCode see my API key in kosa8?

No. The opencode kit brokers it: the sandbox holds a placeholder and a broker on your machine adds the real key on the way to the model provider.

Is there a kosa8 kit for Amp?

Not today. Amp can use kosa8 sandboxes through MCP (kosa8 mcp install amp), which contains the commands it sends there.

Can I use OpenCode with an OpenAI key instead?

Yes. The kit brokers OPENAI_API_KEY as well as ANTHROPIC_API_KEY.

Where do OpenCode's changes go?

Into the folder you shared, which keeps them after the sandbox is removed. Commit before each run so you can review and revert.

06Get started

Install kosa8 on a Mac, Linux or Windows (WSL2) machine, or make an account and run the same sandboxes on kosa8 Cloud.

07Sources

Related

Updated 2026-11-14