perf(chat): trim sub-agent tool noise from wire payload#425
Merged
Conversation
Sessions with heavy sub-agent (Task) use loaded slowly and consumed a lot of bandwidth when opening the Chat panel. The bulk of the payload was sub-agent internal tool_result content (file dumps, command output) and large tool_use inputs (Write/Edit bodies) that the collapsed Agent view never renders — pure dead weight on the wire. Add trimSubAgentForWire: for messages nested under a Task (parent.toolUseId set), empty tool_result content and reduce tool_use input to the single displayed brief field. Apply it at every egress to the frontend — message reads (getBySessionId), the live stream broadcast, and the reconnect catch-up buffer. The DB copy is never touched, so resume, branching/undo, interrupt detection, and the navigation rail/virtual-scroll windowing are all unaffected. Because the trim is display-only, the Debug modal now fetches the full untrimmed sub-agent messages straight from the DB (messages:get-subagents) and rebuilds the complete subActivities, so Debug Information still shows the real, complete data. Trimming is engine-agnostic (keyed on the unified parent.toolUseId and camelCase brief fields). The brief-field whitelist must stay in sync with getToolBrief in the AgentTool variants.
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.
Sessions with heavy sub-agent (Task) use loaded slowly and consumed a lot of bandwidth when opening the Chat panel. The bulk of the payload was sub-agent internal tool_result content (file dumps, command output) and large tool_use inputs (Write/Edit bodies) that the collapsed Agent view never renders — pure dead weight on the wire.
Add trimSubAgentForWire: for messages nested under a Task (parent.toolUseId set), empty tool_result content and reduce tool_use input to the single displayed brief field. Apply it at every egress to the frontend — message reads (getBySessionId), the live stream broadcast, and the reconnect catch-up buffer. The DB copy is never touched, so resume, branching/undo, interrupt detection, and the navigation rail/virtual-scroll windowing are all unaffected.
Because the trim is display-only, the Debug modal now fetches the full untrimmed sub-agent messages straight from the DB (messages:get-subagents) and rebuilds the complete subActivities, so Debug Information still shows the real, complete data.
Trimming is engine-agnostic (keyed on the unified parent.toolUseId and camelCase brief fields). The brief-field whitelist must stay in sync with getToolBrief in the AgentTool variants.