fix(commands): remove unintended config mutation in SwitchModel

SwitchModel should only update the routed agent's runtime Model field.
Writing to cfg.Agents.Defaults.ModelName was a behavioral change that
corrupts the default agent config when switching a non-default agent.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
mingmxren 2026-03-05 22:59:31 +08:00
parent 75f1b58ca0
commit d248c91611

View file

@ -1532,9 +1532,6 @@ func (al *AgentLoop) buildCommandsRuntime(agent *AgentInstance) *commands.Runtim
rt.SwitchModel = func(value string) (string, error) { rt.SwitchModel = func(value string) (string, error) {
oldModel := agent.Model oldModel := agent.Model
agent.Model = value agent.Model = value
if al.cfg != nil {
al.cfg.Agents.Defaults.ModelName = value
}
return oldModel, nil return oldModel, nil
} }
} }