A TUI for managing per-agent model preferences in OpenCode.
Pick a model for each agent or sub-agent, then apply to write preferences to opencode.json.
Requires Go 1.24+.
git clone https://github.com/JRedeker/opencode-model-preferences.git
cd opencode-model-preferences
make installmake install also installs repo-local git hook .git/hooks/pre-push so every future git push rebuilds and reinstalls latest omp first.
Or build without installing:
make build
./ompcd opencode-model-preferences
git pull
make installUpdate flow also refreshes local pre-push hook.
Run omp from any directory:
ompWhen running inside openchad, press Ctrl+b m to open omp in a tmux popup (display-popup -EE, default 80%×80%). Requires tmux ≥3.2.
Override the popup size with OPEN_CHAD_OMP_POPUP_SIZE:
export OPEN_CHAD_OMP_POPUP_SIZE="90%x85%" # percent
export OPEN_CHAD_OMP_POPUP_SIZE="120x40" # absolute cells- Browse managed agents and sub-agents — each shows its current model.
- Press
enterormto pick a model for the selected target. - Press
dto clear a model assignment. - Press
Dto clear all sub-agent overrides when you need them to inherit again. - Press
ato apply all preferences toopencode.json.
The TUI groups targets into three sections:
- Agents — primary and user-facing agents (visible in OpenCode's Tab-cycle)
- Sub-agents — hidden or
mode: subagentagents used internally by plugins and helper flows (e.g.adv-researcher,adv-reviewer,general,explore). These mappings are sticky overrides: changing your main agent model does not change them until you clear them. - ADV Provider Agents — provider-specific ADV orchestrator variants (
adv-claude,adv-gpt,adv-glm,adv-kimi). These are generated by ADV'ssync-global.shfrom the canonicaladv.md. Enable/disable and model are managed here; the canonicaladv.mdis removed from global agents when provider variants are configured.
omp intentionally does not map main agents/overlays build, adv, or plan. Those should follow whatever model you select for current session instead of getting pinned as sticky overrides.
| Key | Action |
|---|---|
enter / m |
Pick model for selected agent |
d |
Clear model assignment |
D |
Clear all sub-agent overrides |
e |
Toggle enable/disable for selected ADV Provider Agent |
a |
Apply preferences to opencode.json |
/ |
Filter the list |
q / ctrl+c |
Quit |
Note: Apply only writes agent entries in
opencode.json. Assigning a model can create a missing agent entry. Clearing a model removes only themodelkey while preserving other agent fields.
Recovery tip: If a hidden sub-agent is pinned to a provider that is rate-limited or unavailable, switching the main agent model will not help until you clear that sub-agent override. Press
Dinomp, then apply.
Preferences are stored in ~/.config/opencode/omp-preferences.json (separate from opencode.json, which does not accept unknown keys). Managed targets exclude build, adv, and plan:
{
"target_models": {
"general": "anthropic/claude-sonnet-4",
"explore": "anthropic/claude-haiku-4"
},
"cleared_models": {
"scout": true
},
"adv_providers": {
"adv-claude": {
"enabled": true,
"model": "anthropic/claude-sonnet-4-20250514"
},
"adv-gpt": {
"enabled": false
}
}
}target_models— maps each target to a model ID. Applying writes these toopencode.json.cleared_models— tracks targets whose model was explicitly cleared. Applying removes themodelkey fromopencode.jsonfor these targets (other fields likemodeare preserved).adv_providers— provider ADV variant configuration. Each entry hasenabled(boolean) and optionalmodel. Applying writesagent.adv-{provider}.disableandagent.adv-{provider}.modeltoopencode.json. Onlyadv-claude,adv-gpt,adv-glm, andadv-kimiare valid keys.
If older omp-preferences.json files still contain build, adv, or plan, omp removes those stale entries automatically on load/save.
On every launch, omp runs opencode models --refresh before loading the config. This ensures the model picker always reflects the latest models from your configured providers.
If the refresh fails, omp exits immediately with an actionable error:
| Failure | Error message |
|---|---|
opencode not in PATH |
opencode binary not found in PATH |
| Non-zero exit (auth/network) | opencode models --refresh failed: … + command output |
| Timeout (>30s) | opencode models --refresh timed out after 30s |
- Built-in agents:
build,plan(primary, locked, not mapped);general,explore(subagent) - Markdown agents:
~/.config/opencode/agents/*.mdand project.opencode/agents/*.md—modeandhiddenfrom frontmatter determine classification - JSON agents: From
agent.*keys inopencode.json(excludes system agents:compaction,title,summary). Agents with"hidden": trueappear in the Sub-agents section.
CLI-first discovery via opencode models output, with fallback to provider.*.models entries in opencode.json.
| Variable | Purpose |
|---|---|
OPENCODE_CONFIG_DIR |
Override config directory (default: ~/.config/opencode) |
OPENCODE_PROJECT_DIR |
Override project root used for .opencode/agents discovery |
OPEN_CHAD_OMP_POPUP_SIZE |
Override tmux popup size when launched via openchad (default: 80%x80%) |
go test ./... # run tests
go vet ./... # lint
make build # build binary
make clean # remove binary