Skip to main content
OpenCode is a terminal coding agent. The tensorlake-opencode plugin redirects the agent’s hands — its file and shell tools — into a Tensorlake sandbox, so the model’s commands and edits run in an isolated environment you control rather than on your laptop.

The model: brain local, hands in the sandbox

OpenCode keeps running locally — the TUI, the model loop, and your session all stay on your machine. The plugin only intercepts the tool calls and routes them to a sandbox: webfetch and websearch are not intercepted — they stay local, since they don’t touch your filesystem. The sandbox itself runs on Tensorlake: fast boot, sub-second resume from a suspended snapshot, and state that persists across OpenCode restarts. See Sandbox lifecycle for the suspend/resume and snapshot model underneath.

Why route tool calls into a sandbox

  • Isolation. The agent’s bash and write never touch your host. A bad command, a runaway install, or an rm lands in a disposable environment, not your working tree.
  • Reproducible environment. Every session gets the same image, CPU, and memory regardless of what’s on the developer’s machine — pin a custom image with the right toolchain once and every session inherits it.
  • State that survives restarts. Sandboxes are named and persisted to disk, so a session reconnects to its sandbox across OpenCode restarts; a suspended sandbox resumes with /tmp/workspace, installed deps, and warm caches intact.

Prerequisites

Setup

1

Add the plugin to your OpenCode config

Add the package name to ~/.config/opencode/opencode.json (create the file if it doesn’t exist):
OpenCode treats bare names as npm packages and installs them into its own cache (~/.cache/opencode/packages/) — you don’t run npm install yourself.
2

Set your API key

Export it in the same shell you launch OpenCode from:
If you use a Personal Access Token instead of a project-scoped key, also set TENSORLAKE_ORGANIZATION_ID and TENSORLAKE_PROJECT_ID.
3

Start OpenCode

On startup the plugin loads but no sandbox is created yet. Confirm it loaded by tailing its log:
You should see a single line: OpenCode started with TensorLake plugin.

Lazy sandbox creation

The sandbox is created lazily, on the first intercepted tool call in a session — not when you launch OpenCode. If you start OpenCode and nothing appears to happen, that’s expected. A session that only uses webfetch/websearch will never spin one up, because neither is intercepted.
To trigger creation, ask the model to run something that uses a file or shell tool:
On that first bash call the plugin provisions the sandbox. You’ll see a “Sandbox created” toast and new log lines:
uname -a will report Linux (the sandbox), confirming the command ran remotely rather than on your Mac.

Verify it’s working

Ask the model to write and read a file back:
The write call routes to sandbox.writeFile() and the read call to sandbox.readFile(), both over the SDK. The agent’s working directory inside the sandbox is /tmp/workspace.

Configure the sandbox

The plugin reads a set of environment variables at sandbox-creation time to decide what the sandbox looks like — its image, CPUs, memory, and disk. There is no config file for this; you set the variables in the shell, then launch OpenCode from that same shell.
The variables are read once, when the sandbox is created (the first intercepted tool call of a session). Set them before you run opencode. Changing a variable in another terminal, or after the sandbox already exists, has no effect on the running session — start a new session to pick up new values.

How it fits together

Every value above describes the sandbox the plugin spins up for that OpenCode session — not OpenCode itself, and not your local machine.

All variables

Making the settings persistent

export only lasts for the current shell. To apply the same sandbox config every time, add the exports to your shell profile (~/.zshrc or ~/.bashrc):
Open a new terminal (or source ~/.zshrc) and every opencode session inherits them.

Use a custom image

TENSORLAKE_IMAGE is the most impactful setting for real work: it lets every OpenCode session start from an environment that already has your language runtimes, system packages, and project dependencies — so the agent isn’t reinstalling them on each session. Register an image, then point the variable at its name:
See Sandbox images for building and managing images.

Next steps

Plugin source

The full plugin: tool interceptors, session manager, and lifecycle handling.

Sandbox lifecycle

The suspend/resume and snapshot model that persists session state.

Sandbox images

Build a custom image so every OpenCode session gets the same toolchain.

Tool calls

The general pattern: expose sandboxes as tools to any LLM agent.