diff --git a/packages/app/src/utils/agent-attention.test.ts b/packages/app/src/utils/agent-attention.test.ts index e05759306..2fc70a20b 100644 --- a/packages/app/src/utils/agent-attention.test.ts +++ b/packages/app/src/utils/agent-attention.test.ts @@ -213,6 +213,40 @@ describe("pickAttentionAgent", () => { ).toBe("older-permission-agent"); }); + it("ignores subagents even when they require attention", () => { + expect( + pickAttentionAgent([ + createAgent({ + id: "subagent", + parentAgentId: "parent-agent", + requiresAttention: true, + attentionReason: "permission", + attentionTimestamp: new Date("2026-01-01T00:00:00.000Z"), + }), + createAgent({ + id: "top-level-agent", + requiresAttention: true, + attentionReason: "finished", + attentionTimestamp: new Date("2026-01-02T00:00:00.000Z"), + }), + ]), + ).toBe("top-level-agent"); + }); + + it("returns null when only subagents require attention", () => { + expect( + pickAttentionAgent([ + createAgent({ + id: "subagent", + parentAgentId: "parent-agent", + requiresAttention: true, + attentionReason: "permission", + attentionTimestamp: new Date("2026-01-01T00:00:00.000Z"), + }), + ]), + ).toBeNull(); + }); + it("ignores agents with requiresAttention true but null reason", () => { expect( pickAttentionAgent([ diff --git a/packages/app/src/utils/agent-attention.ts b/packages/app/src/utils/agent-attention.ts index 8db905a49..a3e5df627 100644 --- a/packages/app/src/utils/agent-attention.ts +++ b/packages/app/src/utils/agent-attention.ts @@ -38,6 +38,10 @@ export function pickAttentionAgent(agents: Agent[]): string | null { continue; } + if (agent.parentAgentId) { + continue; + } + const priority = getAttentionPriority(agent.attentionReason); if (priority === null) { continue;