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)
| 240 | // a hook supplies its own summary so the kept-tail policy stays |
| 241 | // consistent across the two strategies. |
| 242 | func 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 |