Skip to content

Commit 8c5ed1a

Browse files
committed
test(agent): split stuck recovery registry coverage
1 parent 9c3a131 commit 8c5ed1a

2 files changed

Lines changed: 33 additions & 20 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import { afterEach, describe, expect, it, vi } from "vitest";
2+
import { createReplyOperation } from "../../auto-reply/reply/reply-run-registry.js";
3+
import { testing as replyRunTesting } from "../../auto-reply/reply/reply-run-registry.test-support.js";
4+
import { abortEmbeddedAgentRun } from "./runs.js";
5+
import { testing } from "./runs.test-support.js";
6+
7+
describe("embedded-agent runner stuck recovery", () => {
8+
afterEach(() => {
9+
testing.resetActiveEmbeddedRuns();
10+
replyRunTesting.resetReplyRunRegistry();
11+
vi.restoreAllMocks();
12+
});
13+
14+
it("passes stuck recovery abort reasons through reply-run fallback", () => {
15+
const operation = createReplyOperation({
16+
sessionKey: "agent:main:main",
17+
sessionId: "session-reply-run",
18+
resetTriggered: false,
19+
});
20+
const cancel = vi.fn();
21+
operation.attachBackend({
22+
kind: "embedded",
23+
cancel,
24+
isStreaming: () => true,
25+
});
26+
operation.setPhase("running");
27+
28+
expect(abortEmbeddedAgentRun("session-reply-run", { reason: "stuck_recovery" })).toBe(true);
29+
30+
expect(cancel).toHaveBeenCalledWith("stuck_recovery");
31+
expect(operation.result).toEqual({ kind: "aborted", code: "aborted_for_stuck_recovery" });
32+
});
33+
});

src/agents/embedded-agent-runner/runs.test.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -898,26 +898,6 @@ describe("embedded-agent runner run registry", () => {
898898
expect(queueMessage).not.toHaveBeenCalled();
899899
});
900900

901-
it("passes stuck recovery abort reasons through reply-run fallback", () => {
902-
const operation = createReplyOperation({
903-
sessionKey: "agent:main:main",
904-
sessionId: "session-reply-run",
905-
resetTriggered: false,
906-
});
907-
const cancel = vi.fn();
908-
operation.attachBackend({
909-
kind: "embedded",
910-
cancel,
911-
isStreaming: () => true,
912-
});
913-
operation.setPhase("running");
914-
915-
expect(abortEmbeddedAgentRun("session-reply-run", { reason: "stuck_recovery" })).toBe(true);
916-
917-
expect(cancel).toHaveBeenCalledWith("stuck_recovery");
918-
expect(operation.result).toEqual({ kind: "aborted", code: "aborted_for_stuck_recovery" });
919-
});
920-
921901
it("force-clears an aborted run that does not drain", async () => {
922902
vi.useFakeTimers();
923903
try {

0 commit comments

Comments
 (0)