Supported Backends
Coding Backends vs Sandbox
Coding Backends
Local development with full filesystem access. AI reads, writes, and refactors code on your machine.
Sandbox Execution
Isolated containers for safe code execution. Code runs in ephemeral Docker containers.
How It Works
OpenCode backend creates coding sessions that give agents access to your local filesystem:- Session Creation: Agent calls
coding_openwith a workspace path - Code Operations: Agent sends tasks via
codetool - OpenCode’s AI reads, writes, and modifies files - Session End: Agent calls
coding_closeto clean up
Quick Start
1. Install OpenCode
2. Start OpenCode Server
3. Configure Station
Add OpenCode URL to your Station config:4. Create an Agent with Coding Backend
5. Run the Agent
Coding Tools
Whencoding.enabled: true and coding.backend: opencode, agents receive these tools:
Tool Reference
- coding_open
- code
- coding_close
- coding_commit
- coding_push
- coding_branch
Start a new coding session or continue an existing one.To continue an existing session:Returns session ID for subsequent operations.
Backend Options
Station supports three backend options for OpenCode integration:The backend is configured at the Station level (
config.yaml), not per-agent. All agents with coding.enabled: true use the same backend. This keeps agent definitions portable across environments.HTTP Backend (opencode)
Direct HTTP communication with OpenCode. Best for local development where OpenCode runs on the same machine.
NATS Backend (opencode-nats)
Uses NATS messaging for communication. Best for containerized or distributed setups where OpenCode runs remotely or in a container with the Station plugin.
- Running OpenCode in a separate container
- Decoupled architecture (Station and OpenCode can restart independently)
- Multiple Station instances sharing one OpenCode
CLI Backend (opencode-cli)
Spawns opencode run as a subprocess for each task. No server required - OpenCode bootstraps itself on a random port for each execution.
- CI/CD pipelines (GitHub Actions, GitLab CI)
- Serverless environments where you can’t run a persistent server
- Simple setups without infrastructure dependencies
- Session continuation across multiple agent runs
Configuration Reference
HTTP Backend Config
NATS Backend Config
CLI Backend Config
The CLI backend requires
opencode to be installed and available in your PATH. No server needs to be running - each task spawns a fresh OpenCode process.Claude Code Backend Config
Claude Code is Anthropic’s official AI coding agent. It uses your Claude Max/Pro subscription or API key.- Prerequisites
- Authentication
- Quick Start
- Install Claude Code CLI: https://docs.anthropic.com/en/docs/claude-code
- Authenticate: Run
claude loginfor Max/Pro, or setANTHROPIC_API_KEY
Private Repository Authentication
To work with private repositories, configure git credentials in your Station config:- GitHub PAT
- GitHub App
- GitLab
Create a Personal Access Token with
repo scope:- Go to GitHub Settings → Developer Settings → Personal Access Tokens
- Generate a token with
repo(full control of private repositories) - Set it as an environment variable:
When to Use Each Backend
- Decision Matrix
- Architecture Comparison
- Backend Comparison
Long-Running Tasks and Timeouts
Understanding the Timeout
When Station executes agent tools via MCP, each tool call has a timeout. If OpenCode takes longer than 60 seconds to complete a task, the MCP call will fail with a timeout error. Tasks that commonly timeout:- Generating entire project structures (scaffolding)
- Large codebase refactors
- Complex multi-file changes
- Tasks requiring many LLM calls (iterative refinement)
- Single file edits
- Adding/modifying functions
- Code review and analysis
- Simple bug fixes
Solutions for Long-Running Tasks
- Break Into Smaller Tasks
- Use NATS Backend
- Async Execution
Instead of one large task, use multiple smaller ones:Design your agents to work incrementally.
Timeout Configuration
The
task_timeout_min setting only affects the NATS backend. For HTTP backend, you’re constrained by the MCP protocol timeout.Session Continuation (CLI Backend)
The CLI backend supports session continuation - allowing multiple agent runs to share the same OpenCode context. This is useful for:- Multi-step workflows where each step builds on previous work
- Interactive development with human-in-the-loop review
- CI/CD pipelines that need to maintain state across jobs
How It Works
- First run creates a new session (title = your task message)
- Subsequent runs use
--coding-session <name>to continue by title - OpenCode maintains conversation history, file context, and tool state
Using Session Continuation
- CLI Flag
- Tool Parameter
- GitHub Actions
Pass a session name or ID to continue from a previous run:The
--coding-session flag accepts:- Session name - Searches titles (case-insensitive, partial match)
- Session ID - Direct lookup (starts with
ses_)
Listing Sessions
You don’t need to remember session IDs - just use part of the session title. But if you want to see all sessions:Environment Variables
Agent Frontmatter
The agent frontmatter only controls whether coding tools are enabled for that agent. The backend transport (HTTP vs NATS) is determined by Station’s global config. This makes agents portable - the same agent definition works whether Station uses HTTP or NATS backend.
Agent Prompt Template
When creating agents that use coding tools, you must use the{{userInput}} template variable to pass the user’s task to the code tool. Without this, the agent won’t correctly forward the task.
Container Mode (stn up)
When running Station in container mode viastn up, special configuration is needed for OpenCode connectivity.
The Problem
By default, OpenCode binds to127.0.0.1:4096 which is only accessible from localhost. Docker containers cannot reach 127.0.0.1 on the host.
The Solution
Start OpenCode with--hostname 0.0.0.0 to listen on all interfaces:
stn up command automatically rewrites the config:
Verify Connectivity
Architecture
Files created by OpenCode persist on the host machine, not in the container. This is the key difference from sandbox mode.
Example Workflows
Simple File Creation
coding_open({"workspace_path": "/tmp/workspace"})code({"task": "Create hello.py with a hello world function"})coding_close()
/tmp/workspace/hello.py created on your filesystem.
Code Refactoring
coding_open({"workspace_path": "/home/user/my-app"})code({"task": "Read the current database.py implementation"})code({"task": "Refactor to use connection pooling with a pool size of 10"})coding_commit({"message": "Refactor: add database connection pooling"})coding_close()
Full Development Cycle
Troubleshooting
OpenCode Not Responding
Container Can’t Reach OpenCode
Session Errors
If you see “no active session” errors:- Ensure
coding_openwas called first - Check OpenCode logs for connection issues
- Verify workspace path exists and is accessible
Next Steps
OpenCode Container
Run OpenCode in Docker with OAuth
Sandbox Execution
Run code in isolated containers
Agent Development
Create custom agents
Workflows
Multi-step agent orchestration

