Open Laboratory Docs
Autonomous Coding Agent with OpenCode

Autonomous Coding Agent with OpenCode

This guide walks through running an autonomous AI coding agent using OpenCode inside a Laboratory OS desktop environment. The agent operates with full access to the filesystem and terminal inside an isolated container, while you supervise it live from your browser.

Prerequisites

  • Laboratory OS running (GPU not required for the agent itself)
  • An LLM endpoint: either a local vLLM deployment or an external API key (OpenAI, Anthropic, etc.)

Step 1: Install OpenCode

Open the Apps panel from the Laboratory OS desktop and find OpenCode. Click Install.

OpenCode runs inside the container’s desktop environment. Once installed, it appears as a shortcut on the desktop and is accessible via the web desktop at:

https://{your-slug}.tunnels.laboratory.computer

Step 2: Configure the LLM Provider

Open the Laboratory OS desktop in your browser and launch OpenCode from the desktop shortcut.

On first run, OpenCode prompts for your LLM configuration. You have two options:

Option A — Use your local vLLM endpoint

Provider: OpenAI-compatible
Base URL: https://{your-slug}--vllm.tunnels.laboratory.computer/v1
API Key: dummy
Model: Qwen3-30B-A3B

This keeps everything private and on-device — no data leaves your machine.

Option B — Use an external API

Provider: Anthropic / OpenAI / etc.
API Key: your-api-key
Model: claude-sonnet-4-5 / gpt-4o / etc.

External API keys are stored only inside the container and are not exposed outside the tunnel.

Step 3: Give the Agent a Task

In the OpenCode interface, type a task in natural language:

Implement a Python script that watches a directory for new .mp4 files
and automatically transcribes them using whisper.cpp, saving the output
as .srt subtitle files alongside the originals.

OpenCode begins working autonomously. It will:

  1. Read the filesystem to understand the environment
  2. Write code in the editor
  3. Run tests in the terminal
  4. Iterate until the task is complete

Step 4: Supervise via the Web Desktop

While the agent is running, you can watch it work in real time through the Laboratory OS web desktop. The desktop shows:

  • Code editor — files as the agent creates/edits them
  • Terminal — commands the agent is running, with output
  • File browser — filesystem state at any point

You can intervene at any time: type a message to redirect the agent, or take control of the keyboard/mouse directly.

Step 5: Review and Export

When the agent reports completion, review its work:

  • Check the terminal for any failing tests
  • Browse created files in the file browser
  • Open individual files in the code editor for review

To export the output, open the File Browser app and download files directly, or use the terminal to tar and download via the browser.

Safety Considerations

Because OpenCode runs inside a Laboratory OS container, it operates in a fully isolated environment:

  • No host filesystem access — the agent can only touch files inside the container
  • No outbound network access to arbitrary hosts by default — only the configured LLM endpoint and the Laboratory tunnel
  • Observable — every action is visible in the live desktop; nothing happens off-screen

If the agent makes a mistake (deletes a file, breaks a build), you can restore from a container snapshot or simply restart with a fresh container — your host machine is unaffected.

Tips

  • Give the agent a CONTEXT.md file at the root of your project describing the codebase — OpenCode reads it first and produces significantly better results.
  • Use shorter, focused tasks rather than one large task for more reliable output.
  • The agent works best with a powerful reasoning model. For coding tasks, Qwen3-30B-A3B or claude-sonnet-4-5 are good choices.
  • Enable checkpoint mode in OpenCode settings to have the agent commit after each major step, making it easy to review or revert.

What’s Next