Skip to content
This repository was archived by the owner on May 23, 2026. It is now read-only.

Latest commit

 

History

43 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

omp — OpenCode Model Preferences

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.

Install

Requires Go 1.24+.

git clone https://github.com/JRedeker/opencode-model-preferences.git
cd opencode-model-preferences
make install

make 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
./omp

Update

cd opencode-model-preferences
git pull
make install

Update flow also refreshes local pre-push hook.

Usage

Run omp from any directory:

omp

openchad tmux popup

When 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

Flow

  1. Browse managed agents and sub-agents — each shows its current model.
  2. Press enter or m to pick a model for the selected target.
  3. Press d to clear a model assignment.
  4. Press D to clear all sub-agent overrides when you need them to inherit again.
  5. Press a to apply all preferences to opencode.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: subagent agents 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's sync-global.sh from the canonical adv.md. Enable/disable and model are managed here; the canonical adv.md is 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.

Keybinds

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 the model key 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 D in omp, then apply.

Config format

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 to opencode.json.
  • cleared_models — tracks targets whose model was explicitly cleared. Applying removes the model key from opencode.json for these targets (other fields like mode are preserved).
  • adv_providers — provider ADV variant configuration. Each entry has enabled (boolean) and optional model. Applying writes agent.adv-{provider}.disable and agent.adv-{provider}.model to opencode.json. Only adv-claude, adv-gpt, adv-glm, and adv-kimi are valid keys.

If older omp-preferences.json files still contain build, adv, or plan, omp removes those stale entries automatically on load/save.

How it works

Startup model refresh

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

Agent discovery

  • Built-in agents: build, plan (primary, locked, not mapped); general, explore (subagent)
  • Markdown agents: ~/.config/opencode/agents/*.md and project .opencode/agents/*.md — mode and hidden from frontmatter determine classification
  • JSON agents: From agent.* keys in opencode.json (excludes system agents: compaction, title, summary). Agents with "hidden": true appear in the Sub-agents section.

Model discovery

CLI-first discovery via opencode models output, with fallback to provider.*.models entries in opencode.json.

Environment

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%)

Development

go test ./...     # run tests
go vet ./...      # lint
make build        # build binary
make clean        # remove binary

About

OpenCode plugin for per-agent and per-command model preference routing via global config

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages