fix(team-mode): reject coordinator agents as subagent targets (#4027)

Agents could select coordinator/meta agents (Prometheus, Atlas,
Sisyphus/Ultraworker) as subagent targets via task() / delegation,
producing duplicate orchestration loops and conflicting team state.
This is the inverse of #3987 / #4065 — symmetric guard on the
delegation TARGET side, using the same AGENT_ELIGIBILITY_REGISTRY
classification.

Add a runtime guard at the delegation entry point that rejects
task() calls whose subagent_type resolves to an agent marked as
hard-reject / coordinator-only in the eligibility registry, with
an actionable error naming the agent. Regression test asserts a
prometheus-targeted delegation is rejected before any subagent
session spawns.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
ZeyuFu
2026-05-16 02:13:28 -04:00
parent fcb96841f8
commit 7af3007e67
4 changed files with 115 additions and 3 deletions
+2 -2
View File
@@ -4430,8 +4430,8 @@ describe("sisyphus-task", () => {
{ sessionID: "p", messageID: "m", agent: "sisyphus", abort: new AbortController().signal }
)
//#then
expect(result).toContain('Cannot delegate to primary agent "prometheus" via task. Select that agent directly instead.')
//#then — coordinator guard fires before primary-agent check; message names the agent and explains the conflict
expect(result).toContain('Cannot delegate to coordinator agent "prometheus" via task()')
}, { timeout: 20000 })
test("non-plan subagent should NOT have task permission", async () => {