fix(reducer): preserve agent text when message has both text and internal tool-call#1145
Open
AaronZ021 wants to merge 2 commits intoslopus:mainfrom
Open
fix(reducer): preserve agent text when message has both text and internal tool-call#1145AaronZ021 wants to merge 2 commits intoslopus:mainfrom
AaronZ021 wants to merge 2 commits intoslopus:mainfrom
Conversation
…ol call When an assistant message contained both text content and a mcp__happy__change_title tool call, parseMessageAsEvent converted the entire message into an event, discarding the text the user should see. Fix: when the message has meaningful text alongside tool calls, skip event conversion so text flows through normal Phase 1 processing. Also skip mcp__happy__change_title tool calls in Phase 2 so they don't create visible tool messages in the UI. Same fix applies to EnterPlanMode tool calls which had the identical bug.
Extend the internal tool call filter to also skip EnterPlanMode in both Phase 2 (main messages) and Phase 4 (sidechain messages). Also hide mcp__happy__change_title in sidechain processing. These internal tool calls should not appear as visible tool messages.
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.
Problem
When a Claude agent message contains both text content and a tool call to
mcp__happy__change_title,EnterPlanMode, orenter_plan_mode, the user's visible text is silently discarded.Call path
shouldSkipNormalProcessing(msg)is evaluated early in message processing.parseMessageAsEvent(msg)— if any content item is achange_title/EnterPlanModetool-call, the whole message is converted to an event like"Title changed to X"or"Entering plan mode".shouldSkipNormalProcessingreturnstrue, and the reducer never sees the original message. The text content the agent emitted is gone.In practice, Claude often outputs something like:
After this PR: the user sees the explanatory text AND the title updates. Before this PR: the text is silently dropped and the user just sees
Title changed to ….Fix
Two coordinated changes that must land together:
1.
sync/reducer/messageToEvent.ts— inparseMessageAsEvent, if the message has meaningful text content alongside tool calls, returnnullso the message goes through normal rendering. AhasTextcheck excludes theClaude AI usage limit reached|<ts>sentinel (which is legitimately text-only and should still become an event).2.
sync/reducer/reducer.ts— whenparseMessageAsEventreturnsnull, the reducer would otherwise create a visible tool-call UI element formcp__happy__change_title/EnterPlanMode(now reaching Phase 2 and Phase 4 sidechain processing). Skip these internal tool names in both phases so the text renders cleanly without tool-icon clutter.Without change (2), change (1) alone would introduce a regression (text appears, but the tool icon is also shown).
Test coverage
No new tests in this PR. The existing reducer spec suite passes; the regression this fixes is invisible to the current tests because they don't assert that text content survives message-to-event conversion. Happy to add a case if the reviewer would like one.
Scope
Origin
These two commits were carried on a fork for several weeks and proved stable in production use. Extracted onto a clean branch off
upstream/mainfor this PR.Co-authored-by: Claude (Happy AI pair-programming session) noreply@anthropic.com