@@ -1172,6 +1172,51 @@ describe("summarizeConversation", () => {
11721172
11731173 // Non-destructive: the full stored history (hidden messages included) is preserved for rewind.
11741174 expect ( result . messages ) . toHaveLength ( messages . length + 1 )
1175+ expect ( result . messages [ 1 ] ) . toMatchObject ( {
1176+ content : "Hidden assistant message" ,
1177+ truncationParent : truncationId ,
1178+ } )
1179+ expect ( result . messages [ 2 ] ) . toMatchObject ( {
1180+ content : "Hidden tool result" ,
1181+ truncationParent : truncationId ,
1182+ } )
1183+ } )
1184+
1185+ it ( "should build the summarization request from the effective history when a prior summary exists" , async ( ) => {
1186+ const condenseId = "condense-1"
1187+ const truncationId = "trunc-2"
1188+ const messages : ApiMessage [ ] = [
1189+ { role : "user" , content : "Pre-summary task" , ts : 1 , condenseParent : condenseId } ,
1190+ { role : "assistant" , content : "Pre-summary assistant" , ts : 2 , condenseParent : condenseId } ,
1191+ { role : "user" , content : "## Conversation Summary\nPrior summary" , ts : 3 , isSummary : true , condenseId } ,
1192+ { role : "assistant" , content : "Hidden post-summary assistant" , ts : 4 , truncationParent : truncationId } ,
1193+ {
1194+ role : "user" ,
1195+ content : "[Sliding window truncation: 1 messages hidden to reduce context]" ,
1196+ ts : 5 ,
1197+ isTruncationMarker : true ,
1198+ truncationId,
1199+ } ,
1200+ { role : "user" , content : "Visible post-summary user message" , ts : 6 } ,
1201+ ]
1202+
1203+ await summarizeConversation ( {
1204+ messages,
1205+ apiHandler : mockApiHandler ,
1206+ systemPrompt : defaultSystemPrompt ,
1207+ taskId,
1208+ } )
1209+
1210+ const requestMessages = vi . mocked ( mockApiHandler . createMessage ) . mock . calls [ 0 ] [ 1 ]
1211+ const requestContents = requestMessages . map ( ( { content } ) =>
1212+ typeof content === "string" ? content : JSON . stringify ( content ) ,
1213+ )
1214+ expect ( requestContents ) . toEqual ( [
1215+ "## Conversation Summary\nPrior summary" ,
1216+ "[Sliding window truncation: 1 messages hidden to reduce context]" ,
1217+ "Visible post-summary user message" ,
1218+ expect . stringContaining ( "detailed summary of the conversation" ) ,
1219+ ] )
11751220 } )
11761221} )
11771222
0 commit comments