Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

fix(daemon): skip failed workers in heartbeat catalog (#1621)

Sebastian Müller34b294f8318e
diff --git a/packages/coding-agent/.changes/eng-5432-heartbeat-catalog-failed-workers.md b/packages/coding-agent/.changes/eng-5432-heartbeat-catalog-failed-workers.md
new file mode 100644
index 0000000000..f5d028f1d7
--- /dev/null
+++ b/packages/coding-agent/.changes/eng-5432-heartbeat-catalog-failed-workers.md
@@ -0,0 +1 @@
+- Fixed the Agents View heartbeat refresh failing entirely ("Cannot list heartbeats while session worker is failed") when any resident worker was terminally failed: failed workers are now excluded from the global catalog while recovering and disconnected workers still fail closed.
diff --git a/packages/coding-agent/src/modes/daemon/daemon-supervisor.ts b/packages/coding-agent/src/modes/daemon/daemon-supervisor.ts
index b69a4ad1c2..729ec6b3ac 100644
--- a/packages/coding-agent/src/modes/daemon/daemon-supervisor.ts
+++ b/packages/coding-agent/src/modes/daemon/daemon-supervisor.ts
@@ -1859,7 +1859,9 @@ export class DaemonSupervisor {
const match = await this.findWorkerForClient(client, command.activeSessionId);
return this.forwardToWorker(match.worker, command);
}
- const workers = [...this.workers.values()].filter((worker) => this.isLiveWorker(worker));
+ const workers = [...this.workers.values()].filter(
+ (worker) => this.isLiveWorker(worker) && worker.descriptor.lifecycle !== "failed",
+ );
const heartbeats = new Map<string, AgentConnectionHeartbeat>();
const snapshots: Array<{ heartbeats?: AgentConnectionHeartbeat[]; response?: DaemonResponse }> =
await Promise.all(
diff --git a/packages/coding-agent/test/daemon-supervisor-heartbeats.test.ts b/packages/coding-agent/test/daemon-supervisor-heartbeats.test.ts
index 8b4b1d1dbb..68f8f98e45 100644
--- a/packages/coding-agent/test/daemon-supervisor-heartbeats.test.ts
+++ b/packages/coding-agent/test/daemon-supervisor-heartbeats.test.ts
@@ -30,7 +30,7 @@ function createSupervisorHarness(): SupervisorHarness {
}) as unknown as SupervisorHarness;
}
-function worker(lifecycle: "ready" | "recovering", connected = true) {
+function worker(lifecycle: "ready" | "recovering" | "failed", connected = true) {
return {
descriptor: { lifecycle },
...(connected ? { client: {} } : {}),
@@ -139,6 +139,26 @@ describe("daemon supervisor heartbeat aggregation", () => {
expect(supervisor.forwardToWorker).toHaveBeenCalledOnce();
});
+ it("skips terminally failed workers without blocking healthy heartbeats", async () => {
+ const supervisor = createSupervisorHarness();
+ supervisor.workers.set("healthy", worker("ready"));
+ supervisor.workers.set("failed", worker("failed", false));
+ supervisor.forwardToWorker = vi.fn(async (_target, command) =>
+ success(command.id, command.type, { heartbeats: [{ job: { id: "heartbeat-1" } }] }),
+ );
+
+ const response = await supervisor.handleCommand({} as DaemonSocketClient, {
+ id: "list-failed-worker",
+ type: "heartbeats_list",
+ });
+
+ expect(response).toMatchObject({
+ success: true,
+ data: { heartbeats: [{ job: { id: "heartbeat-1" } }] },
+ });
+ expect(supervisor.forwardToWorker).toHaveBeenCalledOnce();
+ });
+
it("routes management by cached job ownership after a session unloads", async () => {
const supervisor = createSupervisorHarness();
const target = {