fix(chat): preserve messages after summarization#3280
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a frontend/backend contract mismatch that caused chat history to disappear from the active “new conversation” view after summarization-triggered stream resets, by broadening the frontend’s summarization update-key matching and improving message deduplication around hidden control messages.
Changes:
- Frontend: preserve visible history across summarization resets by matching any
*.SummarizationMiddleware.before_modelupdate key and moving pre-reset messages into history before the live stream clears. - Frontend: adjust message deduplication/overlap logic to ensure hidden control messages don’t evict visible messages with the same identity.
- Tests: add frontend unit coverage for hidden-message dedupe + update-key matching; add backend regression test to guard the update-key suffix contract.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| frontend/src/core/threads/hooks.ts | Matches summarization updates by stable suffix, preserves visible messages on reset, and avoids hidden-message dedupe issues. |
| frontend/tests/unit/core/threads/message-merge.test.ts | Adds unit tests for hidden-message ID reuse and DeerFlow summarization update-key matching. |
| backend/tests/test_lead_agent_model_resolution.py | Adds regression guard ensuring summarization middleware class name keeps the SummarizationMiddleware.before_model suffix. |
Collaborator
|
@ggnnggez Here are some review comments.
|
# Conflicts: # frontend/src/core/threads/hooks.ts
Collaborator
Author
|
Thanks for the review. Addressed in e584efd
|
WillemJiang
approved these changes
May 29, 2026
jtaynl
added a commit
to jtaynl/deer-flow
that referenced
this pull request
May 29, 2026
- d46a577 fix(chat): preserve messages after summarization (bytedance#3280) Directly relevant to this deployment since we run summarization with the raised 32K trigger (tuning recommendation, 2026-05-23). Prior bug could silently drop post-summary messages from chat history during long research threads. No conflicts on overlap-risk paths. No new gotchas — fix is transparent. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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
Fixed #2965
Root Cause
The backend emits summarization updates under DeerFlowSummarizationMiddleware.before_model, while the frontend only listened for SummarizationMiddleware.before_model. As a result, the frontend missed the summarization reset update and did not move visible messages into local history before RemoveMessage(remove_all) cleared the live stream.
Validation
Note: pnpm typecheck was previously blocked by stale Next generated route types under .next/types versus .next/dev/types, unrelated to this change.