Skip to content

Commit f597ba5

Browse files
committed
test(discord): prove active-turn steer admission
1 parent ec5143a commit f597ba5

2 files changed

Lines changed: 27 additions & 11 deletions

File tree

‎extensions/discord/src/monitor/message-handler.queue.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ describe("createDiscordMessageHandler queue behavior", () => {
191191
expectStatusPatch(setStatus, { activeRuns: 0, busy: false });
192192
});
193193

194-
it("lets a same-session message reach steer admission while the first run is active", async () => {
194+
it("starts a second same-session event while the first run is active", async () => {
195195
preflightDiscordMessageMock.mockReset();
196196
processDiscordMessageMock.mockReset();
197197

‎src/auto-reply/reply/agent-runner.runreplyagent.e2e.test.ts‎

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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";
4347
import { testing as replyRunTesting } from "./reply-run-registry.test-support.js";
4448
import { bindReplyOperationTyping } from "./reply-run-typing.js";
4549
import { 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

Comments
 (0)