executeOnAgentSwitchHooks fires on_agent_switch when the runtime changes the active agent. Observational; failures are logged. The hook runs alongside the existing [AgentSwitching] event, so users who already consume that event see no behaviour change. The previous agent's model-endpoint snapshot i
(ctx context.Context, a *agent.Agent, sessionID, fromAgent, toAgent, kind string)
| 296 | // every agent switch (matches the cheap-when-unused property of the |
| 297 | // other hook callsites). |
| 298 | func (r *LocalRuntime) executeOnAgentSwitchHooks(ctx context.Context, a *agent.Agent, sessionID, fromAgent, toAgent, kind string) { |
| 299 | exec := r.hooksExec(a) |
| 300 | if exec == nil || !exec.Has(hooks.EventOnAgentSwitch) { |
| 301 | return |
| 302 | } |
| 303 | r.dispatchHook(ctx, a, hooks.EventOnAgentSwitch, &hooks.Input{ |
| 304 | SessionID: sessionID, |
| 305 | FromAgent: fromAgent, |
| 306 | ToAgent: toAgent, |
| 307 | AgentSwitchKind: kind, |
| 308 | FromAgentModels: r.fromAgentModels(fromAgent), |
| 309 | }, nil) |
| 310 | } |
| 311 | |
| 312 | // fromAgentModels snapshots the previous agent's configured model |
| 313 | // endpoints into the wire-friendly [hooks.ModelEndpoint] form. Hooks |