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

Function firstKeptSessionIndex

pkg/runtime/compactor/compactor.go:333–338  ·  view source on GitHub ↗

firstKeptSessionIndex translates a split index produced against the chat-message list returned by [gatherCompactionInput] back to an index in sess.Messages, suitable for the new summary's FirstKeptEntry. Out-of-range splits map to len(sess.Messages), matching the "compact everything; keep nothing of

(sess *session.Session, sessIndices []int, splitIdx int)

Source from the content-addressed store, hash-verified

331// sentinel that session.buildSessionSummaryMessages handles by
332// skipping the conversation loop.
333func firstKeptSessionIndex(sess *session.Session, sessIndices []int, splitIdx int) int {
334 if splitIdx >= len(sessIndices) {
335 return len(sess.Messages)
336 }
337 return sessIndices[splitIdx]
338}
339
340// toItems wraps a flat slice of chat messages into session items so a
341// fresh session can be built from them for the compaction sub-run.

Calls

no outgoing calls