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.
This plugin runs on OpenCode. New accounts through my referral link get $5 in usage credits, and I get $5 too:
https://opencode.ai/go?ref=N9H3ZEP22A
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 v2.0.3.
To pin a release, replace main in the URL with a tag such as v0.1.0.
| 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