File: internal/session/store.go
Lines: 795-805, 906
Severity: High
Problem
When fullLoad is false and a session has >500 messages, messages before the 24h cutoff are added to postCPEntries but excluded from allMessages (line 800 continue). The checkpoint summary search at line 906 searches allMessages, not postCPEntries. If the summary was written >24h ago, it's excluded, the checkpoint is silently ignored, and the agent receives raw messages instead of compacted context.
Trigger Scenario
- Long-running session accumulates 500+ messages over >24h
- Checkpoint compaction writes summary message + checkpoint record to JSONL
- User continues session, adding messages within last 24h
- On session reload:
findMessageCutoff computes cutoff at lastMessageTime - 24h
- Summary message is before cutoff → excluded from
allMessages
- Checkpoint record sets
lastCpSummaryMsgID (no cutoff check on checkpoint records)
- Summary search at line 906 iterates
allMessages → not found (summaryIdx = -1)
- Falls through to no-checkpoint path → agent gets raw recent messages instead of compacted context
- Comment at line 695 claims "ContextMessages is unaffected" — this is incorrect
Expected vs Actual
- Expected: Checkpoint summary is found and used even if written >24h ago
- Actual: Checkpoint is silently ignored; agent loses compacted context
Fix
Search for the summary message in postCPEntries (which contains all messages) instead of allMessages, or always include the summary message in allMessages regardless of cutoff.
File:
internal/session/store.goLines: 795-805, 906
Severity: High
Problem
When
fullLoadis false and a session has >500 messages, messages before the 24h cutoff are added topostCPEntriesbut excluded fromallMessages(line 800continue). The checkpoint summary search at line 906 searchesallMessages, notpostCPEntries. If the summary was written >24h ago, it's excluded, the checkpoint is silently ignored, and the agent receives raw messages instead of compacted context.Trigger Scenario
findMessageCutoffcomputes cutoff at lastMessageTime - 24hallMessageslastCpSummaryMsgID(no cutoff check on checkpoint records)allMessages→ not found (summaryIdx = -1)Expected vs Actual
Fix
Search for the summary message in
postCPEntries(which contains all messages) instead ofallMessages, or always include the summary message inallMessagesregardless of cutoff.