@@ -119,13 +119,38 @@ describe("transcript", () => {
119119 } ,
120120 }
121121 const result = formatPart ( part , options )
122- expect ( result ) . toContain ( "Tool: bash" )
122+ expect ( result ) . toContain ( "** Tool: bash** " )
123123 expect ( result ) . toContain ( "**Input:**" )
124124 expect ( result ) . toContain ( '"command": "ls"' )
125125 expect ( result ) . toContain ( "**Output:**" )
126126 expect ( result ) . toContain ( "file1.txt" )
127127 } )
128128
129+ test ( "formats tool output containing triple backticks without breaking markdown" , ( ) => {
130+ const part : Part = {
131+ id : "part_1" ,
132+ sessionID : "ses_123" ,
133+ messageID : "msg_123" ,
134+ type : "tool" ,
135+ callID : "call_1" ,
136+ tool : "bash" ,
137+ state : {
138+ status : "completed" ,
139+ input : { command : "echo '```hello```'" } ,
140+ output : "```hello```" ,
141+ title : "Echo backticks" ,
142+ metadata : { } ,
143+ time : { start : 1000 , end : 1100 } ,
144+ } ,
145+ }
146+ const result = formatPart ( part , options )
147+ // The tool header should not be inside a code block
148+ expect ( result ) . toStartWith ( "**Tool: bash**\n" )
149+ // Input and output should each be in their own code blocks
150+ expect ( result ) . toContain ( "**Input:**\n```json" )
151+ expect ( result ) . toContain ( "**Output:**\n```\n```hello```\n```" )
152+ } )
153+
129154 test ( "formats tool part without details when disabled" , ( ) => {
130155 const part : Part = {
131156 id : "part_1" ,
@@ -144,7 +169,7 @@ describe("transcript", () => {
144169 } ,
145170 }
146171 const result = formatPart ( part , { ...options , toolDetails : false } )
147- expect ( result ) . toContain ( "Tool: bash" )
172+ expect ( result ) . toContain ( "** Tool: bash** " )
148173 expect ( result ) . not . toContain ( "**Input:**" )
149174 expect ( result ) . not . toContain ( "**Output:**" )
150175 } )
0 commit comments