From 4bc1045e0f5b5b91abaf6a0f6b519c1f490d57de Mon Sep 17 00:00:00 2001 From: nickyleach <331803+nickyleach@users.noreply.github.com> Date: Wed, 16 Sep 2026 08:20:31 +0000 Subject: [PATCH] test(server): give the failed-run termination test its own agent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test shared one agent between its cancellable run and its deliberately-failing run. Cancelling the first run made the agent claim its next queued run — the second run — and that claim failed for an unrelated reason, so the intended cancellation never happened. Give the failing run its own agent, so only the intended failure path runs. Co-authored-by: Paperclip --- server/src/__tests__/heartbeat-task-drain.test.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/src/__tests__/heartbeat-task-drain.test.ts b/server/src/__tests__/heartbeat-task-drain.test.ts index 045a4690018..87c854af13e 100644 --- a/server/src/__tests__/heartbeat-task-drain.test.ts +++ b/server/src/__tests__/heartbeat-task-drain.test.ts @@ -292,11 +292,15 @@ describeEmbeddedPostgres("terminateActiveRunsForTaskDrain", () => { // A native run with no bound issue fails deterministically inside the // real cancellation path (`native_cancellation_binding_missing`), so // this proves the loop keeps going past one failed run without a race. + // Give it its own agent: cancelling okRunId claims the next queued run + // for ITS agent, so a shared agent would let that claim reach this run + // first and fail it for an unrelated reason before termination did. + const failingAgentId = await seedAgent(companyId); const failingRunId = randomUUID(); await db.insert(heartbeatRuns).values({ id: failingRunId, companyId, - agentId, + agentId: failingAgentId, invocationSource: "assignment", status: "queued", runtimeMode: "native",