OpenCode Autopilot is a Phase 1 plugin prototype for an autonomous auto mode. It keeps OpenCode moving between turns, classifies tool-call risk, routes risky actions through an LLM judge interface, detects loops, and writes an audit trail.
OpenCode does not include a sandbox by default. Unlike Claude Code, Codex, GitHub Copilot, and others, it runs with full access to your filesystem and network out of the box. When running an autonomous agent like Autopilot, this is especially important to be aware of.
It is highly recommended to run OpenCode inside a sandbox. On Linux and macOS, nono works well (what is nono?):
nono run --allow-cwd --profile opencode -- opencode .This repository currently implements the Phase 1 plugin scaffold and pure logic modules:
- Risk classifier for T1/T2/T3 tool calls
- Trust boundary checks for writable roots, protected paths, and allowed network hosts
- Loop detection for repetition, A/B alternation, step limits, and timeouts
- Judge prompt composition with source-aware remote-output stripping and fail-closed parsing
- Plugin adapter for
tool.execute.before,session.idle, and compaction hooks - Audit log and state persistence under
.opencode/
Prompt Guard and conversational trust-boundary narrowing are intentionally deferred to Phase 2, matching the project plan.
Prerequisites:
- Bun 1.3 or newer
- OpenCode with plugin support
Install dependencies:
bun installRun checks:
bun test
bun run typecheckFor local development in this repository, .opencode/plugins/autopilot.ts registers the plugin and .opencode/agents/auto.md registers the auto primary agent.
To install into another OpenCode project:
- Make sure the target project's
opencode.jsonis valid OpenCode config. It can be as small as:
{
"$schema": "https://opencode.ai/config.json"
}- Install the plugin as a local OpenCode plugin file:
mkdir -p .opencode/plugins
cp /path/to/opencode-autopilot/.opencode/plugins/autopilot.ts .opencode/plugins/autopilot.tsFor this local plugin file to work, keep the opencode-autopilot repository checked out at the path referenced by its import, or adjust the import to point at your checkout's src/index.ts.
Do not run opencode plugin opencode-autopilot: that npm package name is already used by a different project.
- Copy
.opencode/agents/auto.mdto the target project:
mkdir -p .opencode/agents
cp /path/to/opencode-autopilot/.opencode/agents/auto.md .opencode/agents/auto.md- Add Autopilot settings to
.opencode/autopilot.json:
{
"maxSteps": 100,
"timeoutMinutes": 30,
"writableRoots": ["."],
"allowedNetworkHosts": [],
"bashFastScreen": false,
"judgeIncludeRemoteOutputs": false,
"judge": {
"provider": null,
"model": null
}
}- Restart OpenCode and press
Tabuntilautois selected.
You can verify agent discovery before starting the TUI:
opencode debug agent autoOpenCode rejects unknown top-level config keys, so Autopilot settings live in .opencode/autopilot.json:
maxSteps: maximum tool calls before autopilot stopstimeoutMinutes: wall-clock timeout for a sessionwritableRoots: paths where structured writes can be auto-approvedallowedNetworkHosts: hostnames where read-only GET requests can be auto-approvedjudge.provider/judge.model: optional secondary judge model selection
Supported hosted judge providers are anthropic, openai, and google. Set the matching API key in the environment: ANTHROPIC_API_KEY, OPENAI_API_KEY, or GOOGLE_API_KEY. If no supported judge credentials are available, T3 actions fail closed with a denial.
Audit events are written to .opencode/autopilot.log; resumable state is written to .opencode/autopilot-state.json.