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)
| 331 | // sentinel that session.buildSessionSummaryMessages handles by |
| 332 | // skipping the conversation loop. |
| 333 | func 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. |
no outgoing calls