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

Method emitHookDrivenShutdown

pkg/runtime/loop.go:156–171  ·  view source on GitHub ↗

emitHookDrivenShutdown fans out the standard Error / notification(level=error) / on_error stanzas when a hook (post_tool_use or before_llm_call) signals run termination.

(
	ctx context.Context,
	a *agent.Agent,
	sess *session.Session,
	message string,
	events EventSink,
)

Source from the content-addressed store, hash-verified

154// notification(level=error) / on_error stanzas when a hook
155// (post_tool_use or before_llm_call) signals run termination.
156func (r *LocalRuntime) emitHookDrivenShutdown(
157 ctx context.Context,
158 a *agent.Agent,
159 sess *session.Session,
160 message string,
161 events EventSink,
162) {
163 if message == "" {
164 // aggregate() always populates Result.Message on a deny
165 // verdict; the fallback covers any future hook that returns
166 // block without a reason.
167 message = "Agent terminated by a hook."
168 }
169 events.Emit(ErrorWithCodeForSession(sess.ID, ErrorCodeHookBlocked, message))
170 r.notifyError(ctx, a, sess.ID, message)
171}
172
173// finalizeEventChannel performs cleanup at the end of a RunStream goroutine:
174// emits the StreamStopped event, fires hooks, records telemetry, restores the

Callers 3

runHarnessAgentMethod · 0.95
runStreamLoopMethod · 0.95
runTurnMethod · 0.95

Calls 3

notifyErrorMethod · 0.95
ErrorWithCodeForSessionFunction · 0.85
EmitMethod · 0.65

Tested by

no test coverage detected