@@ -389,7 +389,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
389389 expect ( result ) . toEqual ( { queuedFinal : false , counts : { tool : 0 , block : 0 , final : 0 } } ) ;
390390 } ) ;
391391
392- it ( "delivers core no-visible-reply fallback for disallowed empty group turns" , async ( ) => {
392+ it ( "delivers core no-visible-reply fallback for disallowed empty mentioned group turns" , async ( ) => {
393393 setNoAbort ( ) ;
394394 const dispatcher = createDispatcher ( ) ;
395395 const replyResolver = vi . fn ( async ( ) => undefined ) ;
@@ -398,6 +398,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
398398 Surface : "feishu" ,
399399 Provider : "feishu" ,
400400 SessionKey : "agent:main:feishu:group:oc_group" ,
401+ WasMentioned : true ,
401402 } ) ;
402403
403404 const result = await dispatchReplyFromConfig ( {
@@ -426,6 +427,112 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
426427 expect ( result . noVisibleReplyFallbackEligible ) . toBeUndefined ( ) ;
427428 } ) ;
428429
430+ it ( "keeps ambient group turns silent even when silence policy is disallow" , async ( ) => {
431+ setNoAbort ( ) ;
432+ // The fallback exists for a user who asked and got nothing. An undirected
433+ // group turn never draws a visible failure notice, regardless of silence
434+ // policy (#114799: ambient HamVerBot group chatter drew fallback spam).
435+ const dispatcher = createDispatcher ( ) ;
436+ const replyResolver = vi . fn ( async ( ) => undefined ) ;
437+ const ctx = buildTestCtx ( {
438+ ChatType : "group" ,
439+ Surface : "telegram" ,
440+ Provider : "telegram" ,
441+ SessionKey : "agent:main:telegram:group:oc_group" ,
442+ } ) ;
443+
444+ const result = await dispatchReplyFromConfig ( {
445+ ctx,
446+ cfg : {
447+ agents : {
448+ defaults : {
449+ silentReply : {
450+ group : "disallow" ,
451+ } ,
452+ } ,
453+ } ,
454+ } as OpenClawConfig ,
455+ dispatcher,
456+ replyResolver,
457+ } ) ;
458+
459+ expect ( dispatcher . sendFinalReply ) . not . toHaveBeenCalled ( ) ;
460+ expect ( result . noVisibleReplyFallbackDelivered ) . toBeUndefined ( ) ;
461+ expect ( result . noVisibleReplyFallbackEligible ) . toBeUndefined ( ) ;
462+ } ) ;
463+
464+ it ( "keeps room_event turns silent even when silence policy is disallow" , async ( ) => {
465+ setNoAbort ( ) ;
466+ const dispatcher = createDispatcher ( ) ;
467+ const replyResolver = vi . fn ( async ( ) => undefined ) ;
468+ const ctx = buildTestCtx ( {
469+ ChatType : "group" ,
470+ Surface : "telegram" ,
471+ Provider : "telegram" ,
472+ SessionKey : "agent:main:telegram:group:oc_group" ,
473+ InboundEventKind : "room_event" ,
474+ } ) ;
475+
476+ const result = await dispatchReplyFromConfig ( {
477+ ctx,
478+ cfg : {
479+ agents : {
480+ defaults : {
481+ silentReply : {
482+ group : "disallow" ,
483+ } ,
484+ } ,
485+ } ,
486+ } as OpenClawConfig ,
487+ dispatcher,
488+ replyResolver,
489+ } ) ;
490+
491+ expect ( dispatcher . sendFinalReply ) . not . toHaveBeenCalledWith ( {
492+ text : NO_VISIBLE_REPLY_FALLBACK_TEXT ,
493+ } ) ;
494+ expect ( result . noVisibleReplyFallbackDelivered ) . toBeUndefined ( ) ;
495+ expect ( result . noVisibleReplyFallbackEligible ) . toBeUndefined ( ) ;
496+ } ) ;
497+
498+ it ( "keeps room_event turns silent even when they carry a mention" , async ( ) => {
499+ setNoAbort ( ) ;
500+ // A room_event is ambient by construction; a stray WasMentioned/direct
501+ // classification must not promote it to a directed turn (only a command
502+ // turn does, matching the room_event source-reply suppression bypass).
503+ const dispatcher = createDispatcher ( ) ;
504+ const replyResolver = vi . fn ( async ( ) => undefined ) ;
505+ const ctx = buildTestCtx ( {
506+ ChatType : "group" ,
507+ Surface : "telegram" ,
508+ Provider : "telegram" ,
509+ SessionKey : "agent:main:telegram:group:oc_group" ,
510+ InboundEventKind : "room_event" ,
511+ WasMentioned : true ,
512+ } ) ;
513+
514+ const result = await dispatchReplyFromConfig ( {
515+ ctx,
516+ cfg : {
517+ agents : {
518+ defaults : {
519+ silentReply : {
520+ group : "disallow" ,
521+ } ,
522+ } ,
523+ } ,
524+ } as OpenClawConfig ,
525+ dispatcher,
526+ replyResolver,
527+ } ) ;
528+
529+ expect ( dispatcher . sendFinalReply ) . not . toHaveBeenCalledWith ( {
530+ text : NO_VISIBLE_REPLY_FALLBACK_TEXT ,
531+ } ) ;
532+ expect ( result . noVisibleReplyFallbackDelivered ) . toBeUndefined ( ) ;
533+ expect ( result . noVisibleReplyFallbackEligible ) . toBeUndefined ( ) ;
534+ } ) ;
535+
429536 it ( "delivers fallback for mentioned group turns even when group silence is allowed" , async ( ) => {
430537 setNoAbort ( ) ;
431538 const dispatcher = createDispatcher ( ) ;
@@ -525,6 +632,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
525632 Surface : "telegram" ,
526633 Provider : "telegram" ,
527634 SessionKey : "agent:main:telegram:group:oc_group" ,
635+ WasMentioned : true ,
528636 } ) ;
529637
530638 const result = await dispatchReplyFromConfig ( {
@@ -636,6 +744,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
636744 OriginatingChannel : "telegram" ,
637745 OriginatingTo : "telegram:999" ,
638746 SessionKey : "agent:main:slack:group:oc_group" ,
747+ WasMentioned : true ,
639748 } ) ;
640749
641750 const result = await dispatchReplyFromConfig ( {
@@ -677,6 +786,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
677786 OriginatingChannel : "telegram" ,
678787 OriginatingTo : "telegram:999" ,
679788 SessionKey : "agent:main:slack:group:oc_group" ,
789+ WasMentioned : true ,
680790 } ) ;
681791
682792 const result = await dispatchReplyFromConfig ( {
@@ -712,6 +822,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
712822 OriginatingChannel : "telegram" ,
713823 OriginatingTo : "telegram:999" ,
714824 SessionKey : "agent:main:slack:group:oc_group" ,
825+ WasMentioned : true ,
715826 } ) ;
716827
717828 const result = await dispatchReplyFromConfig ( {
@@ -749,6 +860,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
749860 OriginatingChannel : "telegram" ,
750861 OriginatingTo : "telegram:999" ,
751862 SessionKey : "agent:main:slack:group:oc_group" ,
863+ WasMentioned : true ,
752864 } ) ;
753865
754866 const result = await dispatchReplyFromConfig ( {
@@ -790,6 +902,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
790902 Surface : "telegram" ,
791903 Provider : "telegram" ,
792904 SessionKey : "agent:main:telegram:group:oc_group" ,
905+ WasMentioned : true ,
793906 } ) ;
794907
795908 const result = await dispatchReplyFromConfig ( {
@@ -827,6 +940,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
827940 Surface : "telegram" ,
828941 Provider : "telegram" ,
829942 SessionKey : "agent:main:telegram:group:oc_group" ,
943+ WasMentioned : true ,
830944 } ) ;
831945
832946 const result = await dispatchReplyFromConfig ( {
@@ -861,6 +975,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
861975 Surface : "telegram" ,
862976 Provider : "telegram" ,
863977 SessionKey : "agent:main:telegram:group:oc_group" ,
978+ WasMentioned : true ,
864979 } ) ;
865980
866981 const result = await dispatchReplyFromConfig ( {
@@ -905,6 +1020,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
9051020 OriginatingChannel : "telegram" ,
9061021 OriginatingTo : "telegram:999" ,
9071022 SessionKey : "agent:main:slack:group:oc_group" ,
1023+ WasMentioned : true ,
9081024 } ) ;
9091025
9101026 const result = await dispatchReplyFromConfig ( {
@@ -951,6 +1067,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
9511067 Surface : "telegram" ,
9521068 Provider : "telegram" ,
9531069 SessionKey : "agent:main:telegram:group:oc_group" ,
1070+ WasMentioned : true ,
9541071 } ) ;
9551072
9561073 const result = await dispatchReplyFromConfig ( {
@@ -991,6 +1108,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
9911108 Surface : "telegram" ,
9921109 Provider : "telegram" ,
9931110 SessionKey : "agent:main:telegram:group:oc_group" ,
1111+ WasMentioned : true ,
9941112 } ) ;
9951113
9961114 const result = await dispatchReplyFromConfig ( {
@@ -1029,6 +1147,7 @@ describe("sendPolicy deny — suppress delivery, not processing (#53328)", () =>
10291147 Surface : "telegram" ,
10301148 Provider : "telegram" ,
10311149 SessionKey : "agent:main:telegram:group:oc_group" ,
1150+ WasMentioned : true ,
10321151 } ) ;
10331152
10341153 const result = await dispatchReplyFromConfig ( {
0 commit comments