@@ -3565,6 +3565,76 @@ describe("createFollowupRunner messaging delivery and dedupe", () => {
35653565 } ) ;
35663566 } ) ;
35673567
3568+ it ( "routes queued compaction hook messages alongside notifyUser notices (#90185)" , async ( ) => {
3569+ runEmbeddedAgentMock . mockImplementationOnce (
3570+ async ( args : {
3571+ onAgentEvent ?: ( evt : { stream : string ; data : Record < string , unknown > } ) => Promise < void > ;
3572+ } ) => {
3573+ await args . onAgentEvent ?.( {
3574+ stream : "compaction" ,
3575+ data : { phase : "start" , messages : [ "Hook before" ] } ,
3576+ } ) ;
3577+ await args . onAgentEvent ?.( {
3578+ stream : "compaction" ,
3579+ data : { phase : "end" , completed : true , messages : [ "Hook after" ] } ,
3580+ } ) ;
3581+ return { payloads : [ ] , meta : { } } ;
3582+ } ,
3583+ ) ;
3584+ const runner = createFollowupRunner ( {
3585+ typing : createMockTypingController ( ) ,
3586+ typingMode : "instant" ,
3587+ defaultModel : "openai/gpt-5.5" ,
3588+ } ) ;
3589+
3590+ await runner (
3591+ createQueuedRun ( {
3592+ originatingChannel : "discord" ,
3593+ originatingTo : "channel:C1" ,
3594+ messageId : "current-msg-1" ,
3595+ run : {
3596+ config : {
3597+ channels : { discord : { replyToMode : "all" } } ,
3598+ agents : { defaults : { compaction : { notifyUser : true } } } ,
3599+ } ,
3600+ messageProvider : "discord" ,
3601+ } ,
3602+ } ) ,
3603+ ) ;
3604+
3605+ expect ( routeReplyMock ) . toHaveBeenCalledTimes ( 4 ) ;
3606+ expect (
3607+ requireRecord ( requireMockCallArg ( routeReplyMock , 0 ) . payload , "hook start" ) ,
3608+ ) . toMatchObject ( {
3609+ text : "Hook before" ,
3610+ replyToId : "current-msg-1" ,
3611+ replyToCurrent : true ,
3612+ isCompactionNotice : true ,
3613+ } ) ;
3614+ expect (
3615+ requireRecord ( requireMockCallArg ( routeReplyMock , 1 ) . payload , "notice start" ) ,
3616+ ) . toMatchObject ( {
3617+ text : "🧹 Compacting context..." ,
3618+ replyToId : "current-msg-1" ,
3619+ replyToCurrent : true ,
3620+ isCompactionNotice : true ,
3621+ } ) ;
3622+ expect ( requireRecord ( requireMockCallArg ( routeReplyMock , 2 ) . payload , "hook end" ) ) . toMatchObject ( {
3623+ text : "Hook after" ,
3624+ replyToId : "current-msg-1" ,
3625+ replyToCurrent : true ,
3626+ isCompactionNotice : true ,
3627+ } ) ;
3628+ expect (
3629+ requireRecord ( requireMockCallArg ( routeReplyMock , 3 ) . payload , "notice end" ) ,
3630+ ) . toMatchObject ( {
3631+ text : "🧹 Compaction complete" ,
3632+ replyToId : "current-msg-1" ,
3633+ replyToCurrent : true ,
3634+ isCompactionNotice : true ,
3635+ } ) ;
3636+ } ) ;
3637+
35683638 it ( "applies reply-to mode filtering to queued compaction notices" , async ( ) => {
35693639 runPreflightCompactionIfNeededMock . mockImplementationOnce (
35703640 async ( params : {
0 commit comments