@@ -39,7 +39,11 @@ import {
3939 REPLY_OPERATION_RUN_STATE ,
4040 type ReplyOperationRunState ,
4141} from "./reply-operation-run-state.js" ;
42- import { createReplyOperation , type ReplyOperation } from "./reply-run-registry.js" ;
42+ import {
43+ createReplyOperation ,
44+ type ReplyOperation ,
45+ replyRunRegistry ,
46+ } from "./reply-run-registry.js" ;
4347import { testing as replyRunTesting } from "./reply-run-registry.test-support.js" ;
4448import { bindReplyOperationTyping } from "./reply-run-typing.js" ;
4549import { consumeReplyUsageState } from "./reply-usage-state.js" ;
@@ -558,6 +562,12 @@ describe("runReplyAgent active steering", () => {
558562
559563 it ( "injects a steer without claiming a new agent reply" , async ( ) => {
560564 const runState : ReplyOperationRunState = { } ;
565+ const active = createReplyOperation ( {
566+ sessionKey : "main" ,
567+ sessionId : "session" ,
568+ resetTriggered : false ,
569+ } ) ;
570+ active . setPhase ( "running" ) ;
561571 state . beforeAgentReplyHasHooksMock . mockImplementation (
562572 ( hookName ) => hookName === "before_agent_reply" ,
563573 ) ;
@@ -583,16 +593,22 @@ describe("runReplyAgent active steering", () => {
583593 } ,
584594 } ) ;
585595
586- await expect ( run ( ) ) . resolves . toBeUndefined ( ) ;
596+ try {
597+ await expect ( run ( ) ) . resolves . toBeUndefined ( ) ;
587598
588- expect ( runState . admission ) . toEqual ( { status : "accepted" , mode : "steer" } ) ;
589- expect ( state . beforeAgentReplyRunMock ) . not . toHaveBeenCalled ( ) ;
590- expect ( state . queueEmbeddedAgentMessageMock ) . toHaveBeenCalledOnce ( ) ;
591- expect ( state . queueEmbeddedAgentMessageMock ) . toHaveBeenCalledWith (
592- "session" ,
593- "hello" ,
594- expect . objectContaining ( { steeringMode : "all" } ) ,
595- ) ;
599+ expect ( runState . admission ) . toEqual ( { status : "accepted" , mode : "steer" } ) ;
600+ expect ( state . beforeAgentReplyRunMock ) . not . toHaveBeenCalled ( ) ;
601+ expect ( state . queueEmbeddedAgentMessageMock ) . toHaveBeenCalledOnce ( ) ;
602+ expect ( state . queueEmbeddedAgentMessageMock ) . toHaveBeenCalledWith (
603+ "session" ,
604+ "hello" ,
605+ expect . objectContaining ( { steeringMode : "all" } ) ,
606+ ) ;
607+ expect ( state . runEmbeddedAgentMock ) . not . toHaveBeenCalled ( ) ;
608+ expect ( replyRunRegistry . get ( "main" ) ) . toBe ( active ) ;
609+ } finally {
610+ active . complete ( ) ;
611+ }
596612 } ) ;
597613
598614 it ( "does not let before_agent_reply claim an accepted steer" , async ( ) => {
0 commit comments