@@ -230,10 +230,10 @@ test("compress message mode batches individual message summaries", async () => {
230230test ( "compress message mode appends protected prompt info" , async ( ) => {
231231 const sessionID = `ses_message_protect_tag_${ Date . now ( ) } `
232232 const rawMessages = buildMessages ( sessionID )
233- const assistant = rawMessages . find ( ( message ) => message . info . id === "msg-assistant -1" )
234- const part = assistant ?. parts [ 0 ]
233+ const user = rawMessages . find ( ( message ) => message . info . id === "msg-user -1" )
234+ const part = user ?. parts [ 0 ]
235235 if ( part ?. type === "text" ) {
236- part . text = "I mapped the code path . <protect>Always preserve release checklist.</protect>"
236+ part . text = "Investigate the issue . <protect>Always preserve release checklist.</protect>"
237237 }
238238
239239 const state = createSessionState ( )
@@ -263,9 +263,9 @@ test("compress message mode appends protected prompt info", async () => {
263263 topic : "Protected note" ,
264264 content : [
265265 {
266- messageId : "m0002 " ,
267- topic : "Code path note" ,
268- summary : "Captured the assistant 's code-path findings ." ,
266+ messageId : "m0001 " ,
267+ topic : "User request note" ,
268+ summary : "Captured the user 's investigation request ." ,
269269 } ,
270270 ] ,
271271 } ,
@@ -285,6 +285,65 @@ test("compress message mode appends protected prompt info", async () => {
285285 assert . match ( block ?. summary || "" , / A l w a y s p r e s e r v e r e l e a s e c h e c k l i s t \. / )
286286} )
287287
288+ test ( "compress message mode ignores protect tags on ignored user messages" , async ( ) => {
289+ const sessionID = `ses_message_ignored_protect_tag_${ Date . now ( ) } `
290+ const rawMessages = buildMessages ( sessionID )
291+ const user = rawMessages . find ( ( message ) => message . info . id === "msg-user-1" )
292+ const part = user ?. parts [ 0 ] as any
293+ if ( part ?. type === "text" ) {
294+ part . text = "Ignored notification. <protect>Do not preserve ignored note.</protect>"
295+ part . ignored = true
296+ }
297+
298+ const state = createSessionState ( )
299+ const logger = new Logger ( false )
300+ const config = buildConfig ( )
301+ config . compress . protectTags = true
302+ const tool = createCompressMessageTool ( {
303+ client : {
304+ session : {
305+ messages : async ( ) => ( { data : rawMessages } ) ,
306+ get : async ( ) => ( { data : { parentID : null } } ) ,
307+ } ,
308+ } ,
309+ state,
310+ logger,
311+ config,
312+ prompts : {
313+ reload ( ) { } ,
314+ getRuntimePrompts ( ) {
315+ return { compressMessage : "" , compressRange : "" }
316+ } ,
317+ } ,
318+ } as any )
319+
320+ await tool . execute (
321+ {
322+ topic : "Ignored protected note" ,
323+ content : [
324+ {
325+ messageId : "m0001" ,
326+ topic : "Ignored note" ,
327+ summary : "Captured the ignored user message." ,
328+ } ,
329+ ] ,
330+ } ,
331+ {
332+ ask : async ( ) => { } ,
333+ metadata : ( ) => { } ,
334+ sessionID,
335+ messageID : "msg-compress-ignored-protect-tag" ,
336+ } ,
337+ )
338+
339+ const block = Array . from ( state . prune . messages . blocksById . values ( ) ) [ 0 ]
340+ assert . doesNotMatch (
341+ block ?. summary || "" ,
342+ / T h e f o l l o w i n g p r o t e c t e d p r o m p t i n f o r m a t i o n w a s i n c l u d e d i n t h i s c o n v e r s a t i o n v e r b a t i m : / ,
343+ )
344+ assert . doesNotMatch ( block ?. summary || "" , / D o n o t p r e s e r v e i g n o r e d n o t e \. / )
345+ } )
346+
288347test ( "compress message mode stores call id for later duration attachment" , async ( ) => {
289348 const sessionID = `ses_message_compress_duration_${ Date . now ( ) } `
290349 const rawMessages = buildMessages ( sessionID )
0 commit comments