@@ -269,20 +269,30 @@ function workspaceBasename(path: string | null | undefined): string | null {
269269// shown as a short `[type]` marker rather than dropped, so the reader sees
270270// that something was there.
271271function messageText ( msg : TransformationRequestMessage ) : string {
272- const c = msg . content ;
272+ return flattenContent ( msg . content ) ;
273+ }
274+
275+ // Flatten a message/block `content` value to text. `tool_result` blocks carry
276+ // their (compressible) payload in `block.content` — a string or a nested block
277+ // list — not in `block.text`, so without recursing here both the original and
278+ // compressed sides render as a bare `[tool_result]` and the diff sees no change.
279+ function flattenContent ( c : unknown ) : string {
273280 if ( typeof c === "string" ) return c ;
274- if ( Array . isArray ( c ) ) {
275- return c
276- . map ( ( block ) => {
277- if ( ! block || typeof block !== "object" ) return "" ;
278- if ( typeof block . text === "string" ) return block . text ;
279- if ( typeof block . type === "string" ) return `[${ block . type } ]` ;
280- return "" ;
281- } )
282- . filter ( ( s ) => s . length > 0 )
283- . join ( "\n" ) ;
284- }
285- return "" ;
281+ if ( ! Array . isArray ( c ) ) return "" ;
282+ return c
283+ . map ( ( block ) => {
284+ if ( ! block || typeof block !== "object" ) return "" ;
285+ const b = block as { type ?: unknown ; text ?: unknown ; content ?: unknown } ;
286+ if ( typeof b . text === "string" ) return b . text ;
287+ if ( b . content !== undefined ) {
288+ const inner = flattenContent ( b . content ) ;
289+ if ( inner . length > 0 ) return inner ;
290+ }
291+ if ( typeof b . type === "string" ) return `[${ b . type } ]` ;
292+ return "" ;
293+ } )
294+ . filter ( ( s ) => s . length > 0 )
295+ . join ( "\n" ) ;
286296}
287297
288298export function formatRequestMessages ( messages : TransformationRequestMessage [ ] ) : string {
0 commit comments