Repository navigation
Conversation
SummarizationCompactor only checked that a summary reply had text and
shrank the conversation. A reply cut off by the output limit
(finish_reason "length") or a content filter ("content_filter") was
wrapped as a summary and replaced the original messages, silently losing
everything the summary had not reached yet.
Such a reply now raises in _apply_summary, so it goes through the existing
failure policy: by default the failure is logged and the previous history
is kept; with raise_on_failure=True the RuntimeError is propagated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
@HYYAlex is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
This branch has not been deployed
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.
Summary (in my own words)
When compacting chat history, the summary can be cut off or filtered, but the compactor only checks whether the summary has any text, not why it ended. Any text counts as success, so a half-written summary replaces the complete old history. My fix: before using a summary, check its finish reason; if it did not end normally, treat the compaction as failed and keep the original history unchanged.
Related Issues
length) or filtered (content_filter) summary and replaces the conversation with it #13736Proposed Changes:
SummarizationCompactor._apply_summaryonly checked that the summary reply had text and that it shrank the conversation. A reply cut off by the generator's output limit (finish_reason="length") or by a content filter ("content_filter") was wrapped in<conversation_summary>and replaced the original messages. Everything the summary had not reached yet was lost for the rest of the run, and the Agent still finished normally._apply_summarynow raises aRuntimeErrorfor those two finish reasons, before the text is used. The error goes through the existing failure policy: by default it is logged and the previous history (or the last successful partial compaction) is kept, and withraise_on_failure=Trueit is propagated. The sync and async paths share_apply_summary, so both are covered. Replies without afinish_reasonkeep today's behavior. Theraise_on_failuredocstring and a release note describe the change.How did you test it?
test/hooks/compaction/test_summarization.py. Forlengthandcontent_filter: the conversation is kept by default (sync and async), andraise_on_failure=Trueraises with the finish reason in the message. A control test checks that a summary withfinish_reason="stop"is still applied. The new incomplete-summary tests fail without the fix.hatch run test:unit test/hooks/compaction/test_summarization.py: 38 passed.hatch run test:unit(full unit suite): 7563 passed, 0 failed.hatch run fmtandhatch run test:types: clean.Agent+CompactionHook+SummarizationCompactor(script in the linked issue). The history containsORDER-7319, and the summary generator returns a partial summary with the givenfinish_reason:Notes for the reviewer
Only
lengthandcontent_filterare treated as incomplete, matching the finish reasons Haystack's chat generators normalize to. A summary with nofinish_reason(for example from a custom generator) is still accepted, to avoid breaking existing setups.This PR was mostly generated with an AI assistant. I have reviewed the changes and run the relevant tests.
Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.