Centralize model-change TUI notification in the main loop#2044
Draft
dgageot wants to merge 1 commit intodocker:mainfrom
Draft
Centralize model-change TUI notification in the main loop#2044dgageot wants to merge 1 commit intodocker:mainfrom
dgageot wants to merge 1 commit intodocker:mainfrom
Conversation
Add a change-detection mechanism (lastEmittedModelID + emitModelInfo closure) in RunStream that automatically emits AgentInfo only when the effective model actually changes. This is checked before and after each LLM call, covering per-tool overrides, fallback, model picker, cooldowns, and any future model-switching feature — without each one having to remember to notify the TUI. - loop.go: replace 3 scattered manual AgentInfo emissions with emitModelInfo calls driven by the closure - model_picker.go: remove AgentInfo emission from the tool handler; rename setModelAndEmitInfo to setCurrentAgentModel (no longer emits) - agent_delegation.go: use getEffectiveModelID instead of getAgentModelID so agent-switch events reflect active fallback cooldowns Assisted-By: docker-agent
5ca63ba to
ad2a2bc
Compare
krissetto
approved these changes
Mar 11, 2026
gtardif
approved these changes
Mar 11, 2026
trungutt
approved these changes
Mar 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Every feature that switches models (routing, alloy, fallback, model picker, per-tool overrides…) had to manually emit an
AgentInfoevent to update the TUI sidebar. This was scattered across 6+ call sites and easy to forget when adding new features.Solution
Add a change-detection mechanism in
RunStream: alastEmittedModelIDvariable andemitModelInfoclosure that automatically emitsAgentInfoonly when the effective model actually changes. Called before and after each LLM call, it covers all model-switching features uniformly.Changes
loop.go: Replace 3 scattered manualAgentInfoemissions withemitModelInfocallsmodel_picker.go: RemoveAgentInfoemission from tool handler; renamesetModelAndEmitInfo→setCurrentAgentModelagent_delegation.go: UsegetEffectiveModelIDinstead ofgetAgentModelIDso agent-switch events reflect active fallback cooldownsAny future model-switching feature no longer needs to worry about TUI notification — the loop handles it automatically.