fix(control): never render compaction fold summaries as user bubbles#3932
Merged
Conversation
Compaction stores its summary as a user-role message so the model treats it as context, but IsSyntheticUserMessage did not recognize the three fold prefixes. A history reload that races a compaction pass (switch tabs mid-/compact, switch back -> missedTurnDone reload) then rendered the entire fold - tool calls, commands, console digests - as a giant user bubble. Closes #3653
This was referenced Jun 11, 2026
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.
Root cause
Compaction folds store their summary as a user-role message (so the model treats it as plain context):
Compact→<compaction-summary>…(internal/agent/compact.go)SummarizeFrom→Summary of the later conversation (compacted from here on):…SummarizeUpTo→Summary of earlier conversation (compacted up to here):…The chat surfaces filter injected user-role messages through
IsSyntheticUserMessage, but none of the three fold prefixes were registered. In the normal live flow you never notice — the transcript shows the compaction card built from events. The leak needs a history reload that races a compaction pass, which is exactly the repro @cinos-1 nailed down: tab A mid-/compact→ switch to tab B → switch back to A. The return trip seeslocal.running && !backend.running(missedTurnDone), resets the transcript, and re-renders fromHistoryForTab— which faithfully served the raw fold as a giant user bubble full of tool calls, commands, and console digests.Fix
Register the three fold prefixes in
syntheticPrefixes(with the sync note extended tocompact.go), so every history-replay surface — desktop reload, session resume, serve — drops them, matching what the live transcript shows. Table tests cover all three folds plus a guard that an ordinary user message starting with "Summary of…" is not swallowed.Closes #3653