From 23d125755f76ece2db06e3f19a1e2a9a5941cd0e Mon Sep 17 00:00:00 2001 From: Code_G Date: Sat, 11 Apr 2026 13:40:02 +0900 Subject: [PATCH] fix(delegate-task): apply getAgentConfigKey normalization to isPlanAgent isPlanFamily was already fixed to normalize display names via getAgentConfigKey, but isPlanAgent still used raw agentName.toLowerCase() without normalization. Apply the same fix to isPlanAgent for consistency. Also fixes test title: 'returns true for planner' was describing the OLD includes-based behavior (the bug), but the assertion already expected false. Add regression tests covering Metis/Momus/Atlas display names for both functions. Fixes #3312 --- src/tools/delegate-task/constants.ts | 2 +- src/tools/delegate-task/tools.test.ts | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/tools/delegate-task/constants.ts b/src/tools/delegate-task/constants.ts index 3d94c90eb..ba5cbe963 100644 --- a/src/tools/delegate-task/constants.ts +++ b/src/tools/delegate-task/constants.ts @@ -325,7 +325,7 @@ export const PLAN_AGENT_NAMES = ["plan"] */ export function isPlanAgent(agentName: string | undefined): boolean { if (!agentName) return false - const lowerName = agentName.toLowerCase().trim() + const lowerName = getAgentConfigKey(agentName).toLowerCase().trim() return PLAN_AGENT_NAMES.some(name => lowerName === name) } diff --git a/src/tools/delegate-task/tools.test.ts b/src/tools/delegate-task/tools.test.ts index 3e7c242b2..941d0e06a 100644 --- a/src/tools/delegate-task/tools.test.ts +++ b/src/tools/delegate-task/tools.test.ts @@ -191,7 +191,7 @@ describe("sisyphus-task", () => { expect(result).toBe(false) }) - test("returns true for 'planner' (matches via includes('plan'))", () => { + test("returns false for 'planner' (no longer matches via substring)", () => { //#given / #when const result = isPlanAgent("planner") @@ -251,6 +251,13 @@ describe("sisyphus-task", () => { //#given / #when / #then expect(PLAN_AGENT_NAMES).toEqual(["plan"]) }) + + test("returns false for non-plan agent display names (regression: isPlanAgent display-name false-positive)", () => { + //#given / #when / #then + expect(isPlanAgent(getAgentDisplayName("metis"))).toBe(false) + expect(isPlanAgent(getAgentDisplayName("momus"))).toBe(false) + expect(isPlanAgent(getAgentDisplayName("atlas"))).toBe(false) + }) }) describe("isPlanFamily", () => { @@ -296,6 +303,13 @@ describe("sisyphus-task", () => { expect(result).toBe(false) }) + test("returns false for non-plan-family agent display names (regression: isPlanFamily includes() false-positive)", () => { + //#given / #when / #then + expect(isPlanFamily(getAgentDisplayName("metis"))).toBe(false) + expect(isPlanFamily(getAgentDisplayName("momus"))).toBe(false) + expect(isPlanFamily(getAgentDisplayName("atlas"))).toBe(false) + }) + test("PLAN_FAMILY_NAMES contains plan and prometheus", () => { //#given / #when / #then expect(PLAN_FAMILY_NAMES).toEqual(["plan", "prometheus"])