Fix fresh-agent tool result attribution and adjacent tool grouping#474
Merged
Conversation
002365f to
c278ded
Compare
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
Claude Code skill payloads inject as synthetic user turns in the fresh-agent transcript, appearing as fake "You" messages. Additionally, adjacent tool-use/result exchanges render as separate entries instead of being grouped into the preceding assistant turn's activity strip.
What the fix does
Server-side (
normalize.ts):normalizeClaudeTurnnow returnsFreshAgentNormalizedTurn | null— user turns whose content is entirely system context (e.g. Claude skill instruction payloads starting with "Base directory for this skill:") are filtered outnormalizeClaudeItemextracts user-authored text viaextractUserAuthoredText, stripping system context from user text blocksisSyntheticUserTimelineItemfilters synthetic user items from timeline pageslatestTurnIdis derived from the last non-null turn instead of the raw resolution valuenormalizeClaudeTurnBodyreturnsnullfor synthetic turnsClient-side (
FreshAgentTranscript.tsx):isSyntheticToolResultTurnidentifies user-role turns that are entirely tool resultscoalesceSyntheticToolResultTurnsfolds synthetic tool result turns into the preceding assistant turn viaappendTurnItems, or renders them astool-role turns when no preceding assistant turn existsfilterTurnsForDisplayin the display pipelineutils.ts:isSystemContextnow detects Claude Code skill payloads starting with "Base directory for this skill:"Rebase notes
Reconciled with PR #452 (transcript contract) which rewrote
normalizeClaudeTurnandFreshAgentTranscript.tsx:coalesceActivityOnlyTurns/mergeActivityOnlyTurnsremoved on main; synthetic tool result coalescing reimplemented as a standalonecoalesceSyntheticToolResultTurnsstep in the newdisplayTurnspipelineAgentTimelineTurn→ClaudeFreshAgentHistoryTurn,AgentTimelinePage→ClaudeFreshAgentHistoryPageTests
Closes kata jb5w.