You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Auto-compaction duplicates the boundary message into the summarizer input #33329
select in packages/core/src/session/compaction.ts partitions the conversation into head (the text summarized during auto-compaction) and recent (kept verbatim) at a token budget. When the budget boundary lands mid-message, that message is split into a prefix (head) and suffix (recent).
The split branch sets split = index + 1, and split is then used as both the end of head's full-message slice and the start of recent's slice:
head = [...conversation.slice(0, split), splitPrefix] → slice(0, index + 1) includes the full boundary message, then splitPrefix (a truncated copy of that same message) is appended. The boundary message appears twice in head.
head is the exact text fed to the summarizer, so whenever the keep-budget boundary lands mid-message (common for a large tool result) the boundary message is sent to the summarizer twice — full and truncated. This wastes input tokens on every overflow-triggered compaction, can push the summary prompt past the context limit so compaction silently fails to recover from overflow, and feeds the summarizer a self-contradictory full-vs-truncated copy.
Steps to reproduce
Have a conversation where the keep-budget boundary falls in the middle of a message (e.g. a large tool result).
Trigger auto-compaction.
The summarizer input (head) contains the boundary message in full AND its truncated prefix — duplicated.
Confirming this is still reproducible on current main (packages/core/src/session/compaction.ts:148). Adding one observation about the recent tail that may help with the fix:
When the straddling message is split, the recent array starts with splitSuffix — the tail fragment of the split message, without its role prefix (e.g. [User]:). So the first thing the model sees in the retained context is a mid-message fragment, not a complete message.
The fix should ensure the straddling message goes entirely to one side (head or recent), or that the split happens at a message boundary rather than mid-message.
Activity
fix(core): stop duplicating the boundary message in compaction head
fix(core): stop duplicating the boundary message in compaction head
EvolveAegis commentedon Aug 1, 2026
Confirming this is still reproducible on current main (
packages/core/src/session/compaction.ts:148). Adding one observation about the recent tail that may help with the fix:When the straddling message is split, the
recentarray starts withsplitSuffix— the tail fragment of the split message, without its role prefix (e.g.[User]:). So the first thing the model sees in the retained context is a mid-message fragment, not a complete message.The fix should ensure the straddling message goes entirely to one side (head or recent), or that the split happens at a message boundary rather than mid-message.
github-actions commentedon Oct 1, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.