@@ -108,6 +108,27 @@ describe("isHeartbeatOkResponse", () => {
108108 } ) ,
109109 ) . toBe ( false ) ;
110110
111+ expect (
112+ isHeartbeatOkResponse ( {
113+ role : "assistant" ,
114+ content : [
115+ { type : "reasoning" , text : "internal draft" } ,
116+ { type : "output_text" , text : "HEARTBEAT_OK" } ,
117+ ] ,
118+ } ) ,
119+ ) . toBe ( true ) ;
120+
121+ expect (
122+ isHeartbeatOkResponse ( {
123+ role : "assistant" ,
124+ content : [
125+ { type : "thinking" , thinking : "internal draft" } ,
126+ { type : "output_text" , text : "HEARTBEAT_OK" } ,
127+ { type : "image" , image_url : "https://example.com/a.png" } ,
128+ ] ,
129+ } ) ,
130+ ) . toBe ( false ) ;
131+
111132 const toolCallOnlyMessage = {
112133 role : "assistant" ,
113134 content : null ,
@@ -189,6 +210,24 @@ describe("filterHeartbeatTranscriptArtifacts", () => {
189210 }
190211 } ) ;
191212
213+ it ( "removes heartbeat pairs when the ack also contains reasoning blocks" , ( ) => {
214+ const messages = [
215+ { role : "user" , content : HEARTBEAT_TRANSCRIPT_PROMPT } ,
216+ {
217+ role : "assistant" ,
218+ content : [
219+ { type : "reasoning" , text : "thinking..." } ,
220+ { type : "output_text" , text : "HEARTBEAT_OK" } ,
221+ ] ,
222+ } ,
223+ { role : "user" , content : "what model are you" } ,
224+ ] ;
225+
226+ expect ( filterHeartbeatTranscriptArtifacts ( messages , undefined , HEARTBEAT_PROMPT ) ) . toEqual ( [
227+ { role : "user" , content : "what model are you" } ,
228+ ] ) ;
229+ } ) ;
230+
192231 it ( "removes prompt-only interrupted heartbeat spans" , ( ) => {
193232 const messages = [
194233 { role : "user" , content : HEARTBEAT_TRANSCRIPT_PROMPT } ,
0 commit comments