@@ -11,6 +11,7 @@ import type {
1111 SubagentToolCallHistoryItem ,
1212 SubagentToolResponseHistoryItem ,
1313 SubagentThoughtHistoryItem ,
14+ SubagentToolSummaryHistoryItem ,
1415} from '../../types.js' ;
1516import { MarkdownDisplay } from '../../utils/MarkdownDisplay.js' ;
1617import { SubagentToolCallDisplay } from './SubagentToolCallDisplay.js' ;
@@ -25,6 +26,7 @@ type SubagentTurn = {
2526 thought ?: SubagentThoughtHistoryItem ;
2627 toolCall ?: SubagentToolCallHistoryItem ;
2728 toolResponse ?: SubagentToolResponseHistoryItem ;
29+ toolSummary ?: SubagentToolSummaryHistoryItem ;
2830 subagentHistory ?: SubagentHistoryItem [ ] ;
2931} ;
3032
@@ -77,9 +79,17 @@ export const SubagentHistoryDisplay: React.FC<SubagentHistoryDisplayProps> = ({
7779
7880 switch ( item . type ) {
7981 case 'thought' :
80- if ( lastTurn . thought ) {
82+ // If the current turn already contains any tool-related activity,
83+ // this new thought must start a new turn.
84+ if (
85+ lastTurn . toolCall ||
86+ lastTurn . toolResponse ||
87+ lastTurn . toolSummary
88+ ) {
8189 acc . push ( { thought : item } ) ;
8290 } else {
91+ // Otherwise, it's either the first thought of a turn or a
92+ // streaming update to the existing thought.
8393 lastTurn . thought = item ;
8494 }
8595 break ;
@@ -90,6 +100,13 @@ export const SubagentHistoryDisplay: React.FC<SubagentHistoryDisplayProps> = ({
90100 lastTurn . toolCall = item ;
91101 }
92102 break ;
103+ case 'tool_summary' :
104+ if ( lastTurn . toolSummary ) {
105+ acc . push ( { toolSummary : item } ) ;
106+ } else {
107+ lastTurn . toolSummary = item ;
108+ }
109+ break ;
93110 // TODO: Shell tool output is very glitchy.
94111 // TODO: there's a bug when multiple shell tool calls are made in succession (for tool_output_chunk), they get merged into one response.
95112 case 'tool_response' :
@@ -180,6 +197,24 @@ export const SubagentHistoryDisplay: React.FC<SubagentHistoryDisplayProps> = ({
180197 />
181198 </ Box >
182199 ) }
200+ { turn . toolSummary && (
201+ < Box
202+ flexDirection = "column"
203+ marginBottom = { 1 }
204+ width = { availableWidth }
205+ borderStyle = "single"
206+ borderColor = "cyan"
207+ paddingX = { 1 }
208+ paddingY = { 0 }
209+ >
210+ < Text color = "cyan" > Summarized Tool Output:</ Text >
211+ < MarkdownDisplay
212+ text = { turn . toolSummary . data . summary }
213+ isPending = { false }
214+ terminalWidth = { availableWidth - 2 } // Adjust width for padding
215+ />
216+ </ Box >
217+ ) }
183218 </ Box >
184219 ) ;
185220 }
0 commit comments