An OpenCode V2 plugin that adds a best-of-N tool. It runs several candidates for a hard question and a judge picks the winner.
mkdir -p ~/.config/opencode/plugins
curl -fsSL \
https://raw.githubusercontent.com/jadmadi/opencode-max-mode/main/max-mode.ts \
-o ~/.config/opencode/plugins/max-mode.tsFor one project, put it in .opencode/plugins/. Tested against OpenCode
0.0.0-beta-19425.
| Command | Effect |
|---|---|
/max <n> |
Set the default candidate count for the session |
/max |
Show the current default |
/max off |
Clear the default |
The plugin registers a best_of_n tool. Ask the model to use it, or call it
with { prompt, candidates? }. The count defaults to the session setting, or 3.
The cap is 8.
No plugin hook can replace the main turn's response. The context hook only
edits inputs, and only the compaction and title hooks may supply a result. So
best-of-N is a tool the model can call, not an interceptor for the next turn.
The tool runs n parallel ctx.generate.text calls, then one judge call, and
returns the winning text.
Cost multiplies with the candidate count: n calls plus one judge.
Candidates and the judge use the session's model. Some providers do not support
transient generation: OpenCode Go returned Request is missing x-opencode-session
in testing. Set MAX_MODE_MODEL to a working model, for example:
MAX_MODE_MODEL=deepseek/deepseek-flashbun testInspired by MiMoCode's max mode. See NOTICE.
MIT