switchProvider replaces the root agent's provider mid-session and re-registers subagents so they use the new one. Conversation history is kept — it's translated by the new provider on the next Send. Token totals reset because each provider keeps its own accumulator.
(name, model string)
| 307 | // kept — it's translated by the new provider on the next Send. Token totals |
| 308 | // reset because each provider keeps its own accumulator. |
| 309 | func switchProvider(name, model string) error { |
| 310 | p, err := newProviderByName(name, model, activeSysPrompt) |
| 311 | if err != nil { |
| 312 | return err |
| 313 | } |
| 314 | rootAgent.Provider = p |
| 315 | registerSubagents(p) |
| 316 | return nil |
| 317 | } |
| 318 | |
| 319 | // ProviderKind returns the short name of a provider value. Used by /model |
| 320 | // and /provider to display the active backend. |
no test coverage detected