Python: fix: preserve synthetic compaction summaries - #7944
Open
Patel Namraa (Namraa310806) wants to merge 1 commit into
Open
Python: fix: preserve synthetic compaction summaries#7944Patel Namraa (Namraa310806) wants to merge 1 commit into
Patel Namraa (Namraa310806) wants to merge 1 commit into
Conversation
Patel Namraa (Namraa310806)
deployed
to
github-app-auth
August 29, 2026 04:54 — with
GitHub Actions
Active
Patel Namraa (Namraa310806)
deployed
to
github-app-auth
August 29, 2026 04:54 — with
GitHub Actions
Active
Patel Namraa (Namraa310806)
deployed
to
github-app-auth
August 29, 2026 04:54 — with
GitHub Actions
Active
Patel Namraa (Namraa310806)
deployed
to
github-app-auth
August 29, 2026 04:54 — with
GitHub Actions
Active
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.
Motivation & Context
CompactionProvider.before_runcan lose synthetic summary messages created by replacement-based compaction strategies such asToolResultCompactionStrategyandSummarizationStrategy.These strategies create new
Messageobjects to replace messages that are excluded during compaction. However,before_runwas only filtering the existing messages incontext.context_messagesusing object identity. Since the newly created summary messages were not part of those original source lists, they were silently discarded during reconciliation.This could cause the original tool results or conversation history to be removed without retaining the summary that was supposed to replace them.
Fixes #7943.
Description & Review Guide
What are the major changes?
CompactionProvider.before_runto track the source of existing messages before running the compaction strategy.context.context_messagesbuckets from the projected message list after compaction instead of only filtering the original buckets.ToolResultCompactionStrategyandSummarizationStrategy.What is the impact of these changes?
before_strategycompaction are no longer silently dropped.What do you want reviewers to focus on?
CompactionProvider.before_run, especially how existing messages and newly created synthetic messages are assigned back tocontext.context_messages.before_runreconciliation.Related Issue
Fixes #7943
Contribution Checklist