Repository navigation
fix(tui): show agent model in mini status line - #65359
AdityaxDeore wants to merge 1 commit into
Conversation
mini's footer showed the server default (e.g. Tidepool Alpha Free) when launched with --agent, even though requests already went to the agent's frontmatter model. The agent catalog carried no model, and the runtime fell back to sdk.model.default for display. Carry the agent's configured model through the agent catalog and prefer it over the server default when no explicit or session model exists; re-evaluate on agent switch. The agent model stays display-only and is never persisted onto the session. When the agent model is unavailable in the catalog, fall back to the server default with a one-line note in the transcript. Closes anomalyco#65231
There was a problem hiding this comment.
I reproduced the bug on the base branch, and it's fixed here. I used the setup from #65231 (a mock OpenAI-compatible provider and an agent with model: mock/agent-model) and ran mini --agent example from source in a pseudo-terminal, then sent one prompt.
- Base: the status line stayed
example · Tidepool Alpha Free · OpenCode, while the mock receivedagent-model. - This PR: it shows
example · Agent Model From Frontmatter · Mockthroughout. The mock still receivesagent-model, and the turn doesn't send a model.
The mini runtime, model-preference, catalog, variant and boot tests pass (32), and tsc -b is clean.
Public API is unchanged. RunAgent.model is an internal TUI type.
The approach looks sound. The agent model is display-only unless a variant is explicitly requested, and the server default is never pinned.
Things worth addressing:
- Tests: the new runtime tests are much larger than the fix needs (see inline).
- #58264: that open PR covers the same agent-model priority in mini, so maintainers will probably want to settle on one approach.
- Screenshots: I couldn't capture the status line with our tooling, since it can't start
mini --agent. Could you attach a before/after screenshot of the footer?
Related: #50376
| }) | ||
| }) | ||
|
|
||
| describe("agent model in the footer", () => { |
There was a problem hiding this comment.
This block adds about 380 lines for nine cases. Most of that is a custom harness of about 165 lines: deferred promises, a wrapped api.event with waiters, a stubbed resume session, and a Bun.sleep(5000) race inside waitForModel that leaves a 5s timer running after each wait. That makes the tests hard to follow, and the timeout makes them timing-dependent. Could you cut this down to the core cases (fresh session shows the agent model and sends no model; explicit --model wins; unavailable agent model falls back with one warning)? Please also replace the sleep race by awaiting the runtime's own events, or drop it and rely on the test timeout.
Issue for this PR
Closes #65231
Type of change
What does this PR do?
opencode mini --agent exampleshowed the server default (Tidepool Alpha Free · $0.00) in the status line while requests actually went to the agent's frontmatter model. Display-only bug: the server resolves the agent model per step, but mini never saw it — the agent catalog droppedmodel, and the runtime fell back tosdk.model.defaultfor display.The fix carries the agent's configured model through the agent catalog (
RunAgent.model) and prefers it over the server default when no explicit or session model exists, re-evaluating when the agent is switched. Precedence in the footer: explicit--model/ user selection > session's stored model > agent frontmatter model > server default (which is the configured global model when one is set, otherwise the first available free model — matching the full TUI, where the agent model beats the configured model). The agent model is display-only: it is never written onto the session, and turns still send no model so the server keeps resolving per step. If the agent's model isn't in the catalog, the footer falls back to the server default and prints one line in the transcript saying so. An explicitly requested variant (--variant, or cycling) attaches to the agent model, never to the server default.Relation to #58264: I checked it first. Its main commit (
57c5d78a) conflicts with currentdev(inruntime.ts,runtime.test.ts,fixture/catalog.ts), and its base is no longer indevhistory, so I implemented this narrower fix fresh instead of layering on it. I did reuse its fallback-warning pattern (a system line in the transcript). This does not touchModel.default(), session persistence, or cost formatting (the$0.00is 2-decimal rounding of the real $0.00047 cost, not a bug). #63506 (slash command setting a model) is a different update path and stays open; #50795 is out of scope.How did you verify your code works?
Reproduced with the bot's
repro.shfrom the issue (mock OpenAI-compatible server, agentexample.mdwithmodel: mock/agent-model, no globalmodelkey), before and after, on this checkout:Before — footer showed the default while the mock got the agent model:
After — footer shows the agent model, mock still gets it:
Also verified the resumed session (
mini -s <id> --agent example→example · Agent Model From Frontmatter) and explicit--model mock/explicit-model(example · Explicit Model, mock gotexplicit-model).Tests (all from
packages/tui,bun test --timeout 30000):test/mini/runtime.test.ts— 15 pass, 0 fail (9 new agent-model cases: fresh, resumed, configured-global, no-model fallback, explicit wins, agent switch, unavailable + warning, variant retained, variant active never sends the default). The 7 fix-specific cases failed before the fix and pass after; existing 6 pass throughout.test/mini/catalog.shared.test.ts,test/mini/variant.shared.test.ts,test/mini/model-preference.test.ts(new),test/mini/runtime.boot.test.ts,test/mini/session.shared.test.ts,test/mini/footer.test.ts,test/mini/footer.view.test.tsx— 125 pass, 2 skip, 0 fail.bun typecheck(packages/tui): no errors in 1,923 files.bun run typecheck:tsc: exit 0.oxlinton the 9 changed files: 0 warnings, 0 errors.bun run checkdid not complete on this machine (its lint step stalled waiting for confirmation); the per-package typecheck + lint above are green.Consult: ChatGPT only (https://chatgpt.com/c/6b01462f-1be8-83e8-94b6-ab9736ac17c9). Gemini was not run — sign-in unavailable.
Screenshots / recordings
No terminal screenshot — this was verified on a headless VM. The footer captures above are the literal status-line text from
repro.shruns before and after the fix; the script is in the issue if a reviewer wants to re-run it.Checklist
Disclosure: AI coding assistance was used in preparing this change.
Added by the opencode bot (AI-generated).
Related: #50376