fix(agent): clamp flush cursor after repair_message_sequence compacts messages (#44837)#44870
Closed
kyssta-exe wants to merge 1 commit into
Closed
fix(agent): clamp flush cursor after repair_message_sequence compacts messages (#44837)#44870kyssta-exe wants to merge 1 commit into
kyssta-exe wants to merge 1 commit into
Conversation
tonydwb
approved these changes
Jun 12, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Good defensive fix. Clamps _last_flushed_db_idx after repair_message_sequence() compacts the message list, preventing the turn-end flush from skipping assistant/tool chain that now sits at indices below the stale cursor (#44837). Well-commented. No issues found.
Collaborator
2a26755 to
e5fdce0
Compare
Contributor
|
Merged via PR #45260 — your commit was cherry-picked onto current main with your authorship preserved in git log (5d0408d). We added a follow-up on top that rewinds the cursor exactly when repair compacts messages below the flush cursor (a case the min() clamp alone misses). Thanks for the clean diagnosis and fix! |
2 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #44837. repair_message_sequence() merges consecutive user messages in-place, shrinking the messages list. The DB-write cursor (_last_flushed_db_idx) was not clamped after compaction, so the turn-end flush would skip persisting the assistant/tool chain. This fix clamps the cursor after repair and adds a safety guard in _flush_messages_to_session_db.