gatherCompactionInput is a thin wrapper around [session.Session.CompactionInput] that clears compaction-specific fields on the returned chat messages. Cost is per-message bookkeeping already accumulated into sess.TotalCost(); leaving it set would double-count when the summarization session reports
(sess *session.Session)
| 262 | // — lives on Session itself so it can run under sess.mu.RLock and stay |
| 263 | // race-safe against concurrent AddMessage / ApplyCompaction calls. |
| 264 | func gatherCompactionInput(sess *session.Session) ([]chat.Message, []int) { |
| 265 | messages, sessIndices := sess.CompactionInput() |
| 266 | for i := range messages { |
| 267 | messages[i].Cost = 0 |
| 268 | messages[i].CacheControl = false |
| 269 | } |
| 270 | return messages, sessIndices |
| 271 | } |
| 272 | |
| 273 | // extractMessages returns the messages to send to the compaction |
| 274 | // model, plus the index (into sess.Messages) of the first message |