fix(orchestration): do not revive idle tasks from status-free progress (#7172)

This commit is contained in:
Maslin Edwin authored and GitHub committed 2026-08-18 18:09:23 +05:30
1 parent cebac353de
commit 82b8a93802
2 files changed
+39

No files matched your search

@@ -2,6 +2,32 @@ import { describe, expect, it } from "vite-plus/test";
import * as ThreadBackgroundLiveness from "./ThreadBackgroundLiveness.ts";
describe("ThreadBackgroundLiveness", () => {
it("does not let status-free progress restart an idle task", () => {
const liveness = ThreadBackgroundLiveness.make();
liveness.recordTaskLiveness({
threadId: "thread",
taskId: "task",
taskType: undefined,
status: undefined,
kind: "started",
});
liveness.recordTaskLiveness({
threadId: "thread",
taskId: "task",
taskType: undefined,
status: "idle",
kind: "updated",
});
liveness.recordTaskLiveness({
threadId: "thread",
taskId: "task",
taskType: undefined,
status: undefined,
kind: "progress",
});
expect(liveness.getThreadBackgroundLiveness("thread")).toBeNull();
});
it("agents present as working; monitors as monitoring; agents win", () => {
const liveness = ThreadBackgroundLiveness.make();
const threadId = "t-live-1";
@@ -130,6 +130,19 @@ export function make(): ThreadBackgroundLivenessService["Service"] {
return;
}
// Status-free progress is a description tick, not a restart. A delayed
// progress event after idle must not put the task back in the live set
// (#7128).
if (input.kind === "progress" && input.status === undefined) {
const existing = stateByThreadId.get(input.threadId);
const stillLive =
existing !== undefined &&
(existing.agents.has(input.taskId) || existing.monitors.has(input.taskId));
if (!stillLive) {
return;
}
}
drop(input.threadId, input.taskId);
const state = stateFor(input.threadId);
const bucket =