You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
tui: bindable "set as default model for this agent" action in model dialog #47836
The model dialog (/models) supports ctrl+f to favorite a model, but there is no way to persist a model as the default for an agent from the UI. Setting an agent default — including for subagent-mode agents — currently requires hand-editing opencode.json(c) or agent Markdown frontmatter.
Environment
opencode version: 0.0.0-beta-19157
OS: Linux 7.1.6-arch1-1 (x64)
Terminal: ghostty (xterm-ghostty, truecolor)
Shell: /usr/bin/bash
Install/channel: beta
Active plugins: omo-v2 (local), local TUI plugins under ~/.config/opencode/plugins/tui
Reproduction
Open /models in the TUI and highlight a model.
Press ctrl+f — favorite toggles.
Look for a "set as default" action — none exists.
Expected Behavior
A bindable action in the model dialog (e.g. ctrl+d) that sets the highlighted model as the default model for the current agent — equivalent to writing agents.<id>.model in config. Ideally this also works for subagent-mode agents, e.g. reachable from the agent list or a child-session view, since subagent models are otherwise only configurable by editing config files by hand. Subagents that have no configured model silently inherit the parent session model, so there is currently no UI surface at all for controlling what model a subagent runs on.
Actual Behavior
No such action exists. Switching an agent's default model requires manually editing agents.<id>.model in opencode.json(c) or the agent's frontmatter.
Additional Context
/models on a primary session only changes that session's model; it does not persist a per-agent default. As a workaround I built a local TUI plugin with its own agent→model picker dialog that writes agents.<id>.model (format-preserving JSONC edit). The missing built-in pieces are:
A "set as default for this agent" action in the model dialog.
Agent context in that action so it can target subagents, not just the current primary agent.
Framing clarification after looking at the keybind architecture: this doesn't require hardcoding a key. The model dialog already exposes remappable command IDs (model.dialog.favorite, model.dialog.provider), so the request reduces to a single new command — e.g. model.dialog.set_default — that persists the highlighted model as agents.<current-agent>.model in config. Binding it to ctrl+d (or anything else) is then just a keybinds entry in cli.json, same as every other action.
On the "already possible via config" close given to #11209: true for primary agents, and technically true for subagents via agents.<id>.model. But subagent models have no UI surface at all — they aren't shown while running (#38495, #41172, #42367), and the resolution rule (no configured model → inherit parent session model) is silent. Favorites are one keypress in the dialog; agent defaults are hand-edited JSONC. One new command ID closes that gap.
Scope addition after further testing: built-in slash commands cannot be removed or shadowed cleanly, and plugin commands cannot safely take a built-in command id.
Concrete case: a TUI plugin registers a command with slash: { name: "agents" }. The built-in agent.list ("Switch agent") owns that slash name:
Registering a plugin command with the same id (agent.list) is silently dropped — the built-in wins and the plugin command disappears.
keybinds: { "agent.list": "none" } in cli.json removes the keybind but the slash entry remains.
The plugin disable prefix (-) applies to plugins, not built-in commands.
Partial workaround found: keymap layers sort by priority, so a plugin layer with priority > 0 lists its same-named slash command above the built-in, making it the default selection in autocomplete. But the built-in entry remains visible below, and there is no way to remove it.
Requests: (1) allow plugin commands to override built-in command ids instead of being silently dropped, and/or (2) a config surface to hide built-in slash commands. Would fix this request and general TUI customization.
This is a clean, well-scoped TUI feature in packages/app. I've scoped the implementation surface on the v2 branch and confirmed it's feasible:
The model dialog (packages/app/src/providers/models/select-dialog.tsx) already wires a keybinding path and exposes a model selection flow — a new bindable action can hook in the same way ctrl+f favorite is handled (handleDocumentSearchKeydown / the dialog's own keydown handler).
Agent context for targeting a non-primary agent is reachable via the existing agent controls in packages/app/src/composer/model.ts (agents.controls().agents.options / .current), which already surfaces per-agent selection for mentions and model prompt.
Persisting agents.<id>.model needs a config write path; I'll follow the format-preserving JSONC-edit approach used elsewhere in the TUI rather than re-serializing the config.
Both the primary-agent default and the subagent-mode agent default (the harder part — subagents silently inherit the parent session model today) are in scope.
I'll base the work on v2 (per this repo's AGENTS.md) and open a PR once it's implemented and tested.
To restate it: you'd like a bindable action in the /models dialog (next to ctrl+f favorite) that saves the highlighted model as the default for the current agent, the same as writing agents.<id>.model. You'd also like a way to do this for subagent-mode agents, which today have no UI for choosing their model. Right now /models only changes the current session's model, by design, so this would be new behaviour. The maintainers will consider it.
Thanks also for describing your plugin workaround. A plugin can't currently add actions to the built-in model dialog, so I've suggested that plugin API addition to the maintainers as well.
I’d like to contribute this across the TUI, desktop, and web. The goal is one saved model default per agent, honored wherever that agent runs, including CLI and API sessions using the same config.
Proposed interaction: in the existing model picker, choose Set default for agent…, then pick a primary agent or subagent. Show its current default before saving. Normal model selection still changes only the current session; cancel writes nothing. Desktop and web should expose the same action without requiring a keyboard shortcut.
@argszero, are you still working on this? Would a maintainer review the interaction and shared configuration scope before we submit an implementation PR?
I'm not working on this — no branch, nothing local, nothing unpublished. It's yours. Sorry for leaving your question hanging for two and a half months; that silence was mine to break and I didn't.
I can't speak for maintainers on the interaction or on the config scope, so that part still needs one of them. But I read the current tree (dev @ 24cf6eb258) before answering, and a few things might save you a pass:
The per-agent setting already exists in the schema.packages/schema/src/config/agent.ts:12 is model: ConfigModel.Selection.pipe(optional). So this is "write what the schema already accepts", not "add a setting".
A format-preserving writer for opencode.json(c) exists today, but it isn't shared.writePluginConfig in packages/cli/src/commands/handlers/plugin/add.ts:53 reads the file as text, edits only the touched path with jsonc-parsermodify + applyEdits (lines 66–68), and writes temp-then-rename with mode 0600; plugin/remove.ts does the same. That pattern is worth keeping — a JSON.stringify round-trip would drop the comments and key order from a user's config file.
Don't reuse Config.Service for this.packages/cli/src/config/config.ts:83 has the same update(draft) / applyEdits machinery, but its path is cli.json in the global config dir (line 31) — the CLI's own state, not the project config the agent default needs to live in.
packages/core/src/config.ts has no write path at this tip. I found no file write in it, only read, discovery, merge and watch. That is what makes your cross-surface scope the real question: TUI, desktop and web would all have to go through one write path, and there isn't one to share yet.
Your read on the scope looks right to me: one saved default per agent, honored wherever that agent runs, is a config question more than a picker question — the picker is the easy half.
Thanks for looking into this, @argszero, and no worries about the delay. Your pointer to the existing per-agent model setting helped. I ended up building a Manage Agents plugin so people can try the workflow, /agents lets you pick an agent and save its default model without switching models in your current chat. Both clients use the same writer, which updates the global config and preserves JSONC comments.
The plugin also handles fallbacks, but I’d leave those out of a native PR. The part I’d still like in the built-in model picker is small: highlight a model, press a configurable key, and save it as the current agent’s default without selecting it for this chat.
Would maintainers be open to a PR for that action? I’d have it write the global default and leave project overrides alone, unless you’d prefer a different scope.
Activity
abran-labs commentedon Sep 7, 2026
Framing clarification after looking at the keybind architecture: this doesn't require hardcoding a key. The model dialog already exposes remappable command IDs (
model.dialog.favorite,model.dialog.provider), so the request reduces to a single new command — e.g.model.dialog.set_default— that persists the highlighted model asagents.<current-agent>.modelin config. Binding it toctrl+d(or anything else) is then just akeybindsentry incli.json, same as every other action.On the "already possible via config" close given to #11209: true for primary agents, and technically true for subagents via
agents.<id>.model. But subagent models have no UI surface at all — they aren't shown while running (#38495, #41172, #42367), and the resolution rule (no configured model → inherit parent session model) is silent. Favorites are one keypress in the dialog; agent defaults are hand-edited JSONC. One new command ID closes that gap.Related: #38495 #41172 #42367
abran-labs commentedon Sep 7, 2026
Scope addition after further testing: built-in slash commands cannot be removed or shadowed cleanly, and plugin commands cannot safely take a built-in command id.
Concrete case: a TUI plugin registers a command with
slash: { name: "agents" }. The built-inagent.list("Switch agent") owns that slash name:agent.list) is silently dropped — the built-in wins and the plugin command disappears.keybinds: { "agent.list": "none" }incli.jsonremoves the keybind but the slash entry remains.-) applies to plugins, not built-in commands.Partial workaround found: keymap layers sort by
priority, so a plugin layer with priority > 0 lists its same-named slash command above the built-in, making it the default selection in autocomplete. But the built-in entry remains visible below, and there is no way to remove it.Requests: (1) allow plugin commands to override built-in command ids instead of being silently dropped, and/or (2) a config surface to hide built-in slash commands. Would fix this request and general TUI customization.
argszero commentedon Sep 8, 2026
I'd like to work on this.
This is a clean, well-scoped TUI feature in
packages/app. I've scoped the implementation surface on thev2branch and confirmed it's feasible:packages/app/src/providers/models/select-dialog.tsx) already wires a keybinding path and exposes a model selection flow — a new bindable action can hook in the same wayctrl+ffavorite is handled (handleDocumentSearchKeydown/ the dialog's own keydown handler).packages/app/src/composer/model.ts(agents.controls().agents.options/.current), which already surfaces per-agent selection for mentions and model prompt.agents.<id>.modelneeds a config write path; I'll follow the format-preserving JSONC-edit approach used elsewhere in the TUI rather than re-serializing the config.Both the primary-agent default and the subagent-mode agent default (the harder part — subagents silently inherit the parent session model today) are in scope.
I'll base the work on
v2(per this repo's AGENTS.md) and open a PR once it's implemented and tested.opencodejr commentedon Oct 28, 2026
Thanks for the detailed request, @abran-labs!
To restate it: you'd like a bindable action in the
/modelsdialog (next toctrl+ffavorite) that saves the highlighted model as the default for the current agent, the same as writingagents.<id>.model. You'd also like a way to do this forsubagent-mode agents, which today have no UI for choosing their model. Right now/modelsonly changes the current session's model, by design, so this would be new behaviour. The maintainers will consider it.Thanks also for describing your plugin workaround. A plugin can't currently add actions to the built-in model dialog, so I've suggested that plugin API addition to the maintainers as well.
Related issues:
/models, but it saves the global default model rather than a per-agent oneagents.*.modeland use the parent session's modelmodel: provider/model#variant, so the subagent inherits the parent's modelabran-labs commentedon Nov 22, 2026
I’d like to contribute this across the TUI, desktop, and web. The goal is one saved model default per agent, honored wherever that agent runs, including CLI and API sessions using the same config.
Proposed interaction: in the existing model picker, choose Set default for agent…, then pick a primary agent or subagent. Show its current default before saving. Normal model selection still changes only the current session; cancel writes nothing. Desktop and web should expose the same action without requiring a keyboard shortcut.
@argszero, are you still working on this? Would a maintainer review the interaction and shared configuration scope before we submit an implementation PR?
argszero commentedon Nov 24, 2026
I'm not working on this — no branch, nothing local, nothing unpublished. It's yours. Sorry for leaving your question hanging for two and a half months; that silence was mine to break and I didn't.
I can't speak for maintainers on the interaction or on the config scope, so that part still needs one of them. But I read the current tree (
dev@24cf6eb258) before answering, and a few things might save you a pass:packages/schema/src/config/agent.ts:12ismodel: ConfigModel.Selection.pipe(optional). So this is "write what the schema already accepts", not "add a setting".opencode.json(c)exists today, but it isn't shared.writePluginConfiginpackages/cli/src/commands/handlers/plugin/add.ts:53reads the file as text, edits only the touched path withjsonc-parsermodify+applyEdits(lines 66–68), and writes temp-then-rename with mode0600;plugin/remove.tsdoes the same. That pattern is worth keeping — aJSON.stringifyround-trip would drop the comments and key order from a user's config file.Config.Servicefor this.packages/cli/src/config/config.ts:83has the sameupdate(draft)/applyEditsmachinery, but itspathiscli.jsonin the global config dir (line 31) — the CLI's own state, not the project config the agent default needs to live in.packages/core/src/config.tshas no write path at this tip. I found no file write in it, only read, discovery, merge and watch. That is what makes your cross-surface scope the real question: TUI, desktop and web would all have to go through one write path, and there isn't one to share yet.Your read on the scope looks right to me: one saved default per agent, honored wherever that agent runs, is a config question more than a picker question — the picker is the easy half.
abran-labs commentedon Nov 25, 2026
Thanks for looking into this, @argszero, and no worries about the delay. Your pointer to the existing per-agent
modelsetting helped. I ended up building a Manage Agents plugin so people can try the workflow,/agentslets you pick an agent and save its default model without switching models in your current chat. Both clients use the same writer, which updates the global config and preserves JSONC comments.The plugin also handles fallbacks, but I’d leave those out of a native PR. The part I’d still like in the built-in model picker is small: highlight a model, press a configurable key, and save it as the current agent’s default without selecting it for this chat.
Would maintainers be open to a PR for that action? I’d have it write the global default and leave project overrides alone, unless you’d prefer a different scope.