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

Method executePreCompactHooks

pkg/runtime/hooks.go:612–624  ·  view source on GitHub ↗

executePreCompactHooks fires pre_compact just before compaction. The trigger reason ("manual", "auto", "overflow", "tool_overflow") is reported in [hooks.Input.Source]. A terminating verdict skips compaction entirely; AdditionalContext is appended to the compaction prompt so handlers can steer the s

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

Source from the content-addressed store, hash-verified

610// compaction entirely; AdditionalContext is appended to the
611// compaction prompt so handlers can steer the summary.
612func (r *LocalRuntime) executePreCompactHooks(ctx context.Context, sess *session.Session, a *agent.Agent, source string, events EventSink) (skip bool, message, additionalPrompt string) {
613 result := r.dispatchHook(ctx, a, hooks.EventPreCompact, &hooks.Input{
614 SessionID: sess.ID,
615 Source: source,
616 }, events)
617 if result == nil {
618 return false, "", ""
619 }
620 if !result.Allowed {
621 return true, result.Message, ""
622 }
623 return false, "", result.AdditionalContext
624}
625
626// executeSubagentStopHooks fires subagent_stop when a sub-agent
627// (transferred task, background agent, skill sub-session) finishes.

Callers 1

compactWithReasonMethod · 0.95

Calls 1

dispatchHookMethod · 0.95

Tested by

no test coverage detected