From c092370f40faad47b6106b09f7131b530155776b Mon Sep 17 00:00:00 2001 From: BKF-Gitty Date: Sun, 19 Apr 2026 03:01:07 +0300 Subject: [PATCH] fix(subagent): enumerate failure statuses explicitly instead of negating accepted Greptile review on PR 68726 flagged that result.status !== "accepted" would silently enroll any future non-accepted status (e.g. queued/pending) into the role-augmentation path. Switch both the ACP and subagent forward sites to an explicit enumeration of (error | forbidden) so new upstream statuses must opt in deliberately. Behavior unchanged for today's closed union. --- src/agents/tools/sessions-spawn-tool.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/agents/tools/sessions-spawn-tool.ts b/src/agents/tools/sessions-spawn-tool.ts index 44612f826c3..0389391b2cc 100644 --- a/src/agents/tools/sessions-spawn-tool.ts +++ b/src/agents/tools/sessions-spawn-tool.ts @@ -313,10 +313,9 @@ export function createSessionsSpawnTool( }); } } + const isAcpFailure = result.status === "error" || result.status === "forbidden"; return jsonResult( - result.status !== "accepted" && requestedAgentId - ? { ...result, role: requestedAgentId } - : result, + isAcpFailure && requestedAgentId ? { ...result, role: requestedAgentId } : result, ); } @@ -355,10 +354,9 @@ export function createSessionsSpawnTool( }, ); + const isSubagentFailure = result.status === "error" || result.status === "forbidden"; return jsonResult( - result.status !== "accepted" && requestedAgentId - ? { ...result, role: requestedAgentId } - : result, + isSubagentFailure && requestedAgentId ? { ...result, role: requestedAgentId } : result, ); }, };