OpenCode Adapter
The opencode_local adapter runs OpenCode CLI on the host machine as a SLAW agent, supporting multi-provider model routing and resuming sessions across Heartbeats.
Type key: opencode_local
Prerequisites
- OpenCode CLI installed via the official installer:
curl -fsSL https://opencode.ai/install | bash
- API credentials for your chosen provider set in the agent's
envconfig (for exampleOPENAI_API_KEYfor OpenAI models,ANTHROPIC_API_KEYfor Anthropic models)
Configuration
Set adapterType: opencode_local on the agent and provide the config below.
Config fields
| Field | Type | Default | Description |
|---|---|---|---|
cwd | string | — | Absolute working directory; created if missing |
instructionsFilePath | string | — | Absolute path to a markdown file prepended to the run prompt |
model | string | required | Model in provider/model format (see Models) |
variant | string | — | Provider-specific reasoning variant: minimal, low, medium, high, xhigh, or max; passed as --variant |
dangerouslySkipPermissions | boolean | true | Inject a runtime config that allows external_directory access without interactive prompts |
promptTemplate | string | — | Template for the run prompt |
command | string | opencode | Override the OpenCode binary path |
extraArgs | string[] | — | Additional CLI arguments |
env | object | — | Environment variables injected into the agent process |
timeoutSec | number | 0 | Run timeout in seconds |
graceSec | number | 15 | SIGTERM grace period |
Models
OpenCode uses provider/model format. Common choices:
| Model ID | Notes |
|---|---|
openai/gpt-5.2-codex | Default |
openai/gpt-5.4 | Latest GPT |
openai/gpt-5.2 | Standard GPT |
openai/gpt-5.1-codex-max | Max Codex |
openai/gpt-5.1-codex-mini | Budget lane (cheap profile) |
anthropic/claude-sonnet-4-6 | Claude Sonnet via OpenCode |
anthropic/claude-opus-4-8 | Claude Opus via OpenCode |
Run opencode models to list all available models for your configured providers.
Minimal example
{
"adapterType": "opencode_local",
"adapterConfig": {
"cwd": "/home/agent/workspace",
"model": "openai/gpt-5.2-codex",
"dangerouslySkipPermissions": true,
"timeoutSec": 0,
"graceSec": 15
}
}
Session behaviour
SLAW stores the session ID and cwd after each run. On the next Heartbeat, OpenCode resumes the prior session with --session when the stored cwd matches the current working directory.
Notes
modelis required foropencode_local— there is no implicit default that survives across model updates.- Runs are executed as:
opencode run --format json … - SLAW sets
OPENCODE_DISABLE_PROJECT_CONFIG=trueto prevent OpenCode from writing anopencode.jsoninto the project working directory. Model selection is passed via the--modelCLI flag instead. - When
dangerouslySkipPermissionsis enabled, SLAW injects a temporary runtime config withpermission.external_directory=allowso headless runs do not stall on approval prompts. - When SLAW provisions a workspace or runtime, it injects
SLAW_WORKSPACE_*andSLAW_RUNTIME_*environment variables.