Skip to content

/new does not clear per-agent model override within TUI session lifetime #26741

@drsmile1001

Description

@drsmile1001

Description

Two different flows write to modelStore.model[agentName] (a per-agent, in-memory model override in the TUI):

  • User manually selects a model via the model dialog (dialog-model.tsx calls local.model.set()).
  • Session loads and restores the last user message model (prompt/index.tsx calls local.model.set(msg.model) when sessionID changes, line 401).

The second flow fires automatically when navigating into a session — no prompt submission needed. Once set, this override persists for the rest of the TUI process. /new does not clear it.

Scope issue: The session model restoration (per-session intent) writes to a global in-memory key (modelStore.model[agentName], keyed by agent name, not session ID). There is no cleanup path when the session ends.

This means that within one TUI process lifetime, after visiting a session:

  • client.global.config.update() writes to opencode.json correctly
  • But the model indicator continues to show the stale override
  • Only a TUI restart restores the baseline (because modelStore.model is not persisted to disk — only recent/favorite/variant are saved in model.json)

Steps to reproduce

  1. Start TUI on home page.
  2. Call client.global.config.update() with a different model — model indicator updates correctly.
  3. Enter a session (messages load, override is set from the last user message's model).
  4. /new to return to home.
  5. Call client.global.config.update() again with a different model — opencode.json is written, model indicator unchanged.
  6. Restart the TUI — the change from step 5 is now visible.

Suggested fix

Clear modelStore.model[agentName] on /new or session navigation back to home. This lets the lookup chain fall through to the refreshed opencode.json baseline, which is necessary for client.global.config.update() (a public API) to always be effective.

Plugins

Custom TUI plugin calling client.global.config.update()

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions