fix(delegate-task): block self-delegation to prevent infinite recursion

Adds generic self-recursion guard in subagent-resolver using
getAgentConfigKey() to normalize display names and config keys.
Catches athena-junior spawning itself — the only subagent with
task() access not already covered by existing guards.
This commit is contained in:
ismeth
2026-03-27 19:38:56 +01:00
committed by YeonGyu-Kim
parent fc737f8961
commit 2c70ec604d
2 changed files with 10 additions and 0 deletions

View File

@@ -60,6 +60,14 @@ Create the work plan directly - that's your job as the planning agent.`,
}
}
if (parentAgent && getAgentConfigKey(agentName) === getAgentConfigKey(parentAgent)) {
return {
agentToUse: "",
categoryModel: undefined,
error: `Cannot spawn "${agentName}" from within itself. Self-delegation creates infinite recursion. Use category-based delegation to spawn a Sisyphus-Junior worker instead (e.g., category="quick" or category="deep").`,
}
}
let agentToUse = agentName
let categoryModel: DelegatedModelConfig | undefined
let fallbackChain: FallbackEntry[] | undefined = undefined

View File

@@ -530,6 +530,7 @@ describe("executeSyncContinuation - toast cleanup error paths", () => {
task: false,
call_omo_agent: false,
question: false,
switch_agent: false,
write: false,
edit: false,
})
@@ -600,6 +601,7 @@ describe("executeSyncContinuation - toast cleanup error paths", () => {
task: false,
call_omo_agent: false,
question: false,
switch_agent: false,
write: false,
edit: false,
})