From 17c6c4ac1df4e96a386597819c8339e9d4672fe6 Mon Sep 17 00:00:00 2001 From: Mux Date: Sat, 7 Feb 2026 10:47:24 +0100 Subject: [PATCH 1/2] fix: allow both agentId and subagent_type in task tool calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GPT models consistently send both fields, which was rejected by Zod validation. The downstream handler already prefers agentId gracefully — the rejection served no protective purpose. --- src/common/utils/tools/toolDefinitions.ts | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/common/utils/tools/toolDefinitions.ts b/src/common/utils/tools/toolDefinitions.ts index 27de332b15..2c28649b07 100644 --- a/src/common/utils/tools/toolDefinitions.ts +++ b/src/common/utils/tools/toolDefinitions.ts @@ -156,15 +156,6 @@ const TaskToolAgentArgsSchema = z }); return; } - - if (hasAgentId && hasSubagentType) { - ctx.addIssue({ - code: z.ZodIssueCode.custom, - message: "Provide only one of agentId or subagent_type (not both)", - path: ["agentId"], - }); - return; - } }); export const TaskToolArgsSchema = TaskToolAgentArgsSchema; From 2f927a02846e2d7ecd1fe0e305aa26bab4758060 Mon Sep 17 00:00:00 2001 From: Mux Date: Sat, 7 Feb 2026 10:59:58 +0100 Subject: [PATCH 2/2] refine: reject only conflicting agentId/subagent_type values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address Codex review — allow identical values (GPT's common pattern) but reject when both are provided with different agent IDs, since the handler silently prefers agentId and would run the wrong agent. --- src/common/utils/tools/toolDefinitions.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/common/utils/tools/toolDefinitions.ts b/src/common/utils/tools/toolDefinitions.ts index 2c28649b07..16e6a78e70 100644 --- a/src/common/utils/tools/toolDefinitions.ts +++ b/src/common/utils/tools/toolDefinitions.ts @@ -156,6 +156,17 @@ const TaskToolAgentArgsSchema = z }); return; } + + // GPT models often send both fields with identical values — allow that. + // Only reject when they conflict, since the handler silently prefers agentId. + if (hasAgentId && hasSubagentType && args.agentId !== args.subagent_type) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: "agentId and subagent_type must match when both are provided", + path: ["agentId"], + }); + return; + } }); export const TaskToolArgsSchema = TaskToolAgentArgsSchema;