Skip to content

fix: compaction overflow recovery and failed compaction history#1

Open
noamzbr wants to merge 2 commits intobentrd:fix/413-overflow-recoveryfrom
noamzbr:fix/compaction-overflow-fixes
Open

fix: compaction overflow recovery and failed compaction history#1
noamzbr wants to merge 2 commits intobentrd:fix/413-overflow-recoveryfrom
noamzbr:fix/compaction-overflow-fixes

Conversation

@noamzbr
Copy link

@noamzbr noamzbr commented Feb 26, 2026

Fixes a few issues we ran into with anomalyco#14707 when testing against some sessions from our production env:

  1. When overflow triggers compaction, exclude the large message from the compaction request and replay it after — otherwise the compaction itself overflows on the same content
  2. Skip isOverflow check during compaction — a successful compaction consuming 156K tokens was being flagged as another overflow, killing its own summary
  3. Don't treat failed compaction summaries as history truncation boundaries in filterCompacted

- When overflow triggers compaction, exclude the large message from
  summarization and replay it after, so the model can actually answer it
- Skip the isOverflow check during compaction itself — it was treating
  the compaction's own token usage as another overflow, killing the
  successful summary
- Don't let a failed compaction act as a history boundary — only
  successful ones should truncate prior context
When the overflow-causing message has large images attached, replaying
it raw would just overflow again. Now we replace media parts with text
placeholders before replay, same as toModelMessages does with stripMedia.

Also extracted a shared isMedia() helper to avoid duplicating the
image/pdf check in three places.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants