fromAgentModels snapshots the previous agent's configured model endpoints into the wire-friendly [hooks.ModelEndpoint] form. Hooks that act on the previous agent's models (e.g. the stock `unload` builtin) read this slice instead of poking at the runtime, so the hook payload stays self-contained. Re
(fromAgent string)
| 318 | // Returns nil when there is no previous agent or the lookup fails so |
| 319 | // the JSON wire payload omits the field via `omitempty`. |
| 320 | func (r *LocalRuntime) fromAgentModels(fromAgent string) []hooks.ModelEndpoint { |
| 321 | if fromAgent == "" { |
| 322 | return nil |
| 323 | } |
| 324 | from, err := r.team.Agent(fromAgent) |
| 325 | if err != nil { |
| 326 | slog.Debug("on_agent_switch: from-agent lookup failed", |
| 327 | "agent", fromAgent, "error", err) |
| 328 | return nil |
| 329 | } |
| 330 | configured := from.ConfiguredModels() |
| 331 | out := make([]hooks.ModelEndpoint, 0, len(configured)) |
| 332 | for _, p := range configured { |
| 333 | cfg := p.BaseConfig() |
| 334 | out = append(out, hooks.ModelEndpoint{ |
| 335 | Provider: cfg.ModelConfig.Provider, |
| 336 | Model: cfg.ModelConfig.Model, |
| 337 | BaseURL: cfg.BaseURL, |
| 338 | UnloadAPI: cfg.ModelConfig.UnloadAPI(), |
| 339 | }) |
| 340 | } |
| 341 | return out |
| 342 | } |
| 343 | |
| 344 | // executeOnSessionResumeHooks fires on_session_resume when the user |
| 345 | // explicitly approves continuation past the configured |
no test coverage detected