@@ -283,6 +283,32 @@ describe("summarizeConversation", () => {
283283 const mockCallArgs = ( maybeRemoveImageBlocks as Mock ) . mock . calls [ 0 ] [ 0 ] as any [ ]
284284 expect ( mockCallArgs [ mockCallArgs . length - 1 ] ) . toEqual ( expectedFinalMessage )
285285 } )
286+ it ( "should include the original first user message in summarization input" , async ( ) => {
287+ const messages : ApiMessage [ ] = [
288+ { role : "user" , content : "Initial ask" , ts : 1 } ,
289+ { role : "assistant" , content : "Ack" , ts : 2 } ,
290+ { role : "user" , content : "Follow-up" , ts : 3 } ,
291+ { role : "assistant" , content : "Response" , ts : 4 } ,
292+ { role : "user" , content : "More" , ts : 5 } ,
293+ { role : "assistant" , content : "Later" , ts : 6 } ,
294+ { role : "user" , content : "Newest" , ts : 7 } ,
295+ ]
296+
297+ await summarizeConversation ( messages , mockApiHandler , defaultSystemPrompt , taskId , DEFAULT_PREV_CONTEXT_TOKENS )
298+
299+ const mockCallArgs = ( maybeRemoveImageBlocks as Mock ) . mock . calls [ 0 ] [ 0 ] as any [ ]
300+
301+ // Expect the original first user message to be present in the messages sent to the summarizer
302+ const hasInitialAsk = mockCallArgs . some (
303+ ( m ) =>
304+ m . role === "user" &&
305+ ( typeof m . content === "string"
306+ ? m . content === "Initial ask"
307+ : Array . isArray ( m . content ) &&
308+ m . content . some ( ( b : any ) => b . type === "text" && b . text === "Initial ask" ) ) ,
309+ )
310+ expect ( hasInitialAsk ) . toBe ( true )
311+ } )
286312
287313 it ( "should calculate newContextTokens correctly with systemPrompt" , async ( ) => {
288314 const messages : ApiMessage [ ] = [
0 commit comments