opencode-advisor
v0.3.0
Published
Advisor tool plugin for OpenCode — consults a stronger model in a forked session and returns concise guidance
Downloads
32
Maintainers
Readme
opencode-advisor
Advisor tool plugin for OpenCode.
Adds an explicit advisor tool that consults a stronger model in a temporary forked session and returns concise strategic guidance.
This is an advisor-pattern approximation, not Claude's native server-side advisor API.
Install
npm install opencode-advisorAdd to ~/.config/opencode/opencode.jsonc (or your project's .opencode/opencode.jsonc):
{
"plugin": ["opencode-advisor@latest"]
}Quick start
- Install the plugin.
- Create either
~/.config/opencode/plugins/advisor-config.jsonfor a global default or.opencode/plugins/advisor-config.jsoninside a project for a local override. - Set
advisorModelto the stronger model you want to consult. - Start opencode normally — the plugin will inject guidance telling the model to call
advisoronly when genuinely blocked.
Typical usage
The model will usually call the tool with inputs like:
{
"question": "What boundary should own validation in this refactor?",
"blocker": "Parser and repository still depend on each other, so I cannot split the module safely.",
"attempted": "I first extracted helper functions and then tried interface-based decoupling, but both versions still leave a circular dependency.",
"context": "Current module mixes parsing, validation, and persistence. I already found circular dependencies between parser.ts and repository.ts."
}How it works
The plugin registers a custom advisor tool.
When the model calls advisor, the plugin:
- forks the current session at the current message,
- sends a focused prompt to a stronger model,
- returns the advisor's text back as a tool result,
- deletes the temporary advisor session.
This gives you a practical advisor workflow inside opencode without patching core internals.
parent session
└─ advisor tool call
├─ fork current session
├─ prompt stronger model
├─ collect text response
└─ delete temporary advisor sessionConfiguration
You can place advisor-config.json in either of these locations:
- Global:
~/.config/opencode/plugins/advisor-config.json - Project-local:
.opencode/plugins/advisor-config.json
Precedence is:
- Environment variables
- Project-local config
- Global config
- Built-in defaults
Example:
{
"advisorModel": "anthropic/claude-opus-4-5",
"advisorSystem": null,
"maxAdvisorCalls": 1,
"debug": false
}Fields
| Field | Type | Description |
|---|---|---|
| advisorModel | string \| null | Model to use in provider/model format. If null, the forked session uses its default model. |
| advisorSystem | string \| null | Optional custom system prompt for the advisor session. |
| maxAdvisorCalls | number | Per-session call budget. Defaults to 1. 0 means unlimited. |
| debug | boolean | Print initialization and advisor call logs. |
Example model setups
{ "advisorModel": "anthropic/claude-opus-4-5" }{ "advisorModel": "github-copilot/claude-opus-4.6" }{ "advisorModel": "openai/o3" }Environment variables
| Variable | Values | Description |
|---|---|---|
| ADVISOR_MODEL | provider/model | Override advisorModel |
| ADVISOR_SYSTEM | string | Override advisorSystem |
| ADVISOR_MAX_CALLS | integer | Override per-session advisor call budget |
| ADVISOR_DEBUG | true | Enable debug logging |
Usage notes
- The plugin injects a system prompt telling the model when to call
advisor. advisoris intended for genuine blockers after the model has already tried at least one concrete approach.- Calls should include the decision to make, the blocker, and what has already been attempted.
- No custom agent files are required for this plugin.
- The per-session advisor call budget is cleared automatically when the session is deleted.
- This plugin does not provide Claude-native
advisor_tool_result, single-request sub-inference, or native advisor billing semantics.
Limitations
- Each advisor call is an extra session round-trip.
- The advisor runs in a forked opencode session, not inside the provider's native server-side tool loop.
- Native Claude advisor API behavior is out of scope without opencode core/provider support.
Development
Run tests with:
bun testPackaging note
This package is intended for the opencode/Bun plugin loader.
The published entrypoint intentionally points to index.ts rather than a separate transpiled CommonJS build.
License
MIT
