@@ -410,7 +410,8 @@ describe("monitorLineProvider lifecycle", () => {
410410 accountId : "default" ,
411411 turn : { record : { } } ,
412412 } as unknown as Parameters < typeof onMessage > [ 0 ] ,
413- { } as Parameters < typeof onMessage > [ 1 ] ,
413+ // Admission always hands the turn its live config; an empty one is unreachable.
414+ { cfg : { } } as Parameters < typeof onMessage > [ 1 ] ,
414415 ) ;
415416
416417 const prepared = resolvedTurn ?. delivery . preparePayload ?.( {
@@ -434,6 +435,64 @@ describe("monitorLineProvider lifecycle", () => {
434435 }
435436 } ) ;
436437
438+ it ( "paces block replies with the humanDelay the turn's own config carries" , async ( ) => {
439+ // humanDelay lives on the agent, but only the dispatcher can act on it, so a
440+ // turn that never forwards it paces every block reply at zero.
441+ const { setLineRuntime } = await import ( "./runtime.js" ) ;
442+ type ResolvedTurn = { dispatcherOptions ?: { humanDelay ?: unknown } } ;
443+ let resolvedTurn : ResolvedTurn | undefined ;
444+ const runTurn = async ( params : {
445+ adapter : { resolveTurn : ( ) => ResolvedTurn } ;
446+ } ) : Promise < { dispatched : false } > => {
447+ resolvedTurn = params . adapter . resolveTurn ( ) ;
448+ return { dispatched : false } ;
449+ } ;
450+ setLineRuntime ( {
451+ channel : { inbound : { run : runTurn } } ,
452+ } as unknown as Parameters < typeof setLineRuntime > [ 0 ] ) ;
453+ const monitor = await monitorLineProvider ( {
454+ channelAccessToken : "token" ,
455+ channelSecret : "secret" , // pragma: allowlist secret
456+ config : { } as OpenClawConfig ,
457+ runtime : { } as RuntimeEnv ,
458+ } ) ;
459+ const onMessage = createLineBotMock . mock . calls [ 0 ] ?. [ 0 ] ?. onMessage ;
460+ if ( ! onMessage ) {
461+ throw new Error ( "expected the LINE bot to receive an inbound message handler" ) ;
462+ }
463+
464+ try {
465+ await onMessage (
466+ {
467+ ctxPayload : { From : "line:U1" , MessageSid : "m1" , RawBody : "hi" } ,
468+ replyToken : "reply-token" ,
469+ route : { accountId : "default" , agentId : "ops" , sessionKey : "line:U1" } ,
470+ isGroup : false ,
471+ accountId : "default" ,
472+ turn : { record : { } } ,
473+ } as unknown as Parameters < typeof onMessage > [ 0 ] ,
474+ {
475+ // The per-agent entry wins, so a turn reading only the defaults would
476+ // pace at the wrong interval rather than not at all.
477+ cfg : {
478+ agents : {
479+ defaults : { humanDelay : { mode : "natural" } } ,
480+ entries : { ops : { humanDelay : { mode : "custom" , minMs : 3_000 , maxMs : 4_000 } } } ,
481+ } ,
482+ } ,
483+ } as Parameters < typeof onMessage > [ 1 ] ,
484+ ) ;
485+
486+ expect ( resolvedTurn ?. dispatcherOptions ?. humanDelay ) . toEqual ( {
487+ mode : "custom" ,
488+ minMs : 3_000 ,
489+ maxMs : 4_000 ,
490+ } ) ;
491+ } finally {
492+ await monitor . stop ( ) ;
493+ }
494+ } ) ;
495+
437496 it ( "carries a group's skill scope into the turn that answers it" , async ( ) => {
438497 // The scope is configured per group but enforced per turn: it only applies
439498 // if the reply options reaching the agent carry it.
@@ -470,7 +529,8 @@ describe("monitorLineProvider lifecycle", () => {
470529 skillFilter : [ "triage" ] ,
471530 turn : { record : { } } ,
472531 } as unknown as Parameters < typeof onMessage > [ 0 ] ,
473- { } as Parameters < typeof onMessage > [ 1 ] ,
532+ // Admission always hands the turn its live config; an empty one is unreachable.
533+ { cfg : { } } as Parameters < typeof onMessage > [ 1 ] ,
474534 ) ;
475535
476536 expect ( resolvedTurn ?. replyOptions ?. skillFilter ) . toEqual ( [ "triage" ] ) ;
0 commit comments