Skip to content

Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.

fix(web): stop counting a workflow coordinator as a working agent (#6672)

Rishet119bdd91293316
diff --git a/packages/client-runtime/src/state/subagentRuntime.test.ts b/packages/client-runtime/src/state/subagentRuntime.test.ts
index ceb405175..ff0aea7c8 100644
--- a/packages/client-runtime/src/state/subagentRuntime.test.ts
+++ b/packages/client-runtime/src/state/subagentRuntime.test.ts
@@ -383,13 +383,49 @@ describe("deriveAgentPanelModel", () => {
it("counts idle deliberately and waiting as active", () => {
const model = deriveAgentPanelModel({ agents: roster });
expect(model.idleCount).toBe(1);
- // wf-1 coordinator + member 1 running.
- expect(model.runningCount).toBeGreaterThanOrEqual(1);
+ // Member 1 is running; the wf-1 coordinator is a container, not a worker.
+ expect(model.runningCount).toBe(1);
+ // Every agent lands in exactly one bucket, except coordinators that stand
+ // in for their members.
expect(model.idleCount + model.runningCount + model.waitingCount + model.settledCount).toBe(
- roster.length,
+ roster.length - 1,
);
});
+ it("omits a workflow coordinator from the working-agent count", () => {
+ const model = deriveAgentPanelModel({ agents: roster });
+ // One member still running plus one idle direct spawn. The coordinator
+ // reports running for the whole workflow and must not inflate the banner.
+ expect(model.liveCount).toBe(1);
+ });
+
+ it("omits a finished workflow coordinator from the settled count", () => {
+ const finished = fold([
+ activity("task.started", { taskId: "wf-2", taskType: "local_workflow", title: "sweep" }),
+ activity("task.progress", {
+ taskId: "wf-2:wf:0",
+ title: "sweep:a",
+ status: "completed",
+ parentAgentId: "wf-2",
+ agentIndex: 0,
+ phaseIndex: 0,
+ }),
+ activity("task.completed", {
+ taskId: "wf-2:wf:0",
+ status: "completed",
+ parentAgentId: "wf-2",
+ }),
+ activity("task.completed", { taskId: "wf-2", status: "completed" }),
+ ]);
+
+ const model = deriveAgentPanelModel({ agents: finished });
+
+ // Only the member settled. The coordinator stands in for it, so counting
+ // both would report two finished agents where one ran.
+ expect(model.settledCount).toBe(1);
+ expect(model.liveCount).toBe(0);
+ });
+
it("keeps direct spawns in first-seen order as their activity changes", () => {
const directRoster = fold([
activity("task.started", { taskId: "direct-a", title: "First" }, "2026-08-01T11:00:00.000Z"),
diff --git a/packages/client-runtime/src/state/subagentRuntime.ts b/packages/client-runtime/src/state/subagentRuntime.ts
index e5f2b586b..c1ea1cc2b 100644
--- a/packages/client-runtime/src/state/subagentRuntime.ts
+++ b/packages/client-runtime/src/state/subagentRuntime.ts
@@ -826,15 +826,16 @@ export function deriveAgentPanelModel({
let settledCount = 0;
let totalTokens = 0;
for (const agent of source) {
+ // A workflow coordinator with members is a container for those members, not
+ // work of its own: it reports running for the whole run and aggregates their
+ // usage upstream in some providers. Counting it would report one more agent
+ // working than there are, and double count tokens.
+ if (agent.kind === "workflow" && (members.get(agent.id) ?? []).length > 0) continue;
if (agent.status === "running" || agent.status === "pending") runningCount += 1;
else if (agent.status === "waiting") waitingCount += 1;
else if (agent.status === "idle") idleCount += 1;
else settledCount += 1;
- // Workflow coordinators aggregate member usage upstream in some providers;
- // avoid double counting by only summing leaf agents when members exist.
- if (agent.kind !== "workflow" || (members.get(agent.id) ?? []).length === 0) {
- totalTokens += agent.usage?.totalTokens ?? 0;
- }
+ totalTokens += agent.usage?.totalTokens ?? 0;
}
return {