MCPcopy Index your code
hub / github.com/docker/docker-agent / executeOnAgentSwitchHooks

Method executeOnAgentSwitchHooks

pkg/runtime/hooks.go:298–310  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

296// every agent switch (matches the cheap-when-unused property of the
297// other hook callsites).
298func (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

Calls 4

hooksExecMethod · 0.95
dispatchHookMethod · 0.95
fromAgentModelsMethod · 0.95
HasMethod · 0.45