mirror of
https://mirror.skon.top/github.com/code-yeongyu/oh-my-opencode
synced 2026-04-23 02:23:52 +08:00
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:
@@ -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
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user