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

Function ComputeFirstKeptEntry

pkg/runtime/compactor/compactor.go:242–245  ·  view source on GitHub ↗

ComputeFirstKeptEntry returns the index in sess.Messages of the first message preserved verbatim after compaction, given the [keepTokenBudget] window for contextLimit. Used by the runtime when a hook supplies its own summary so the kept-tail policy stays consistent across the two strategies.

(sess *session.Session, contextLimit int64)

Source from the content-addressed store, hash-verified

240// a hook supplies its own summary so the kept-tail policy stays
241// consistent across the two strategies.
242func ComputeFirstKeptEntry(sess *session.Session, contextLimit int64) int {
243 messages, sessIndices := gatherCompactionInput(sess)
244 return firstKeptSessionIndex(sess, sessIndices, compaction.SplitIndexForKeep(messages, keepTokenBudget(contextLimit)))
245}
246
247// gatherCompactionInput is a thin wrapper around
248// [session.Session.CompactionInput] that clears compaction-specific

Callers 2

summaryFromHookFunction · 0.92

Calls 4

SplitIndexForKeepFunction · 0.92
gatherCompactionInputFunction · 0.85
firstKeptSessionIndexFunction · 0.85
keepTokenBudgetFunction · 0.85

Tested by 1