feat: add summarization compactor - #12296
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
sjrl
force-pushed
the
fix-sliding-window
branch
from
August 11, 2026 07:29
85bd98e to
1a971d5
Compare
sjrl
force-pushed
the
feat/summarization-compactor
branch
from
August 11, 2026 07:29
fbf90d6 to
695a56b
Compare
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||||||||||||||||||||
This was referenced Aug 11, 2026
…eepset-ai/haystack into codex/chat-generator-parameter-mapping
sjrl
force-pushed
the
feat/summarization-compactor
branch
from
August 13, 2026 11:06
cc63567 to
64dddb8
Compare
sjrl
changed the base branch from
main
to
codex/chat-generator-parameter-mapping
August 13, 2026 11:06
sjrl
commented
Aug 13, 2026
Base automatically changed from
codex/chat-generator-parameter-mapping
to
main
August 13, 2026 14:31
…rization-compactor
… the conversation gets longer
…de of chronological order
anakin87
requested changes
Aug 19, 2026
anakin87
left a comment
Member
There was a problem hiding this comment.
The implementation looks reasonable and quite clear to me
I left some (initial) minor comments
anakin87
reviewed
Aug 19, 2026
anakin87
reviewed
Aug 19, 2026
anakin87
approved these changes
Aug 19, 2026
anakin87
left a comment
Member
There was a problem hiding this comment.
Looks good!
Let's remember to document it in a future PR
Contributor
Author
yup that's coming next! |
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.
Related Issues
Proposed Changes:
Added the experimental
SummarizationCompactor, which progressively summarizes a conversation until it fits a target token budget. This preserves useful context from long-running Agents instead of dropping older messages outright.The compactor reads the conversation as two regions. History runs from the end of the leading system messages up to the latest real user message; the current task runs from that user message to the end. It always summarizes history before the current task. Within each region, it summarizes original messages before combining existing summaries. When a historical turn contains both original messages and an existing summary, it summarizes the whole turn together to preserve chronological context. Each round uses the first applicable tier in this order:
historical_turns: Starting with the oldest, summarize as few turns that still contain original messages as needed to reach the target.historical_summaries: When no original messages remain in history, combine as few of its oldest summaries as needed to reach the target.current_task_steps: Summarize the fewest oldest steps needed to reach the target while preserving themin_keep_stepsnewest steps.current_task_summaries: When no more steps can be summarized, combine as few of the current task's oldest summaries as needed to reach the target.Each summary records the summarization strategy and the number of messages it replaced under the
context_compactionkey in itsmeta.Compaction has a floor it cannot go below: the leading system messages, one combined historical summary, the latest user message, one combined current-task summary, and the
min_keep_stepsnewest steps. Once the conversation is reduced to that state,compactreturnsNonebecause there is nothing left that may be given up, even if the result is still above the target.approximate_summary_tokensis the expected length of each summary. It is an estimate used to plan how much of the conversation to summarize, not a limit imposed on the model. A higher value summarizes more of the conversation per round and is more likely to bring the result under the target, at the cost of giving up more context. Configure any generation limit directly on the Chat Generator.A generated summary is only applied when it reduces the measured conversation size; a response with no usable text is treated as a failure. By default, a failed summarization logs a warning and preserves any progress already made. Set
raise_on_failure=Trueto propagate the error instead.How did you test it?
Added new tests.
Notes for the reviewer
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.