fix(subagents): scope allowlist agent id for multi_subagent

This commit is contained in:
Thomas Beaudouin 2026-05-03 13:09:50 +00:00
parent cced8789f9
commit ec891b4edf

View file

@ -306,10 +306,10 @@ func registerSharedTools(
// spawn_status which are added below — preventing recursive // spawn_status which are added below — preventing recursive
// subagent spawning. // subagent spawning.
subagentManager.SetTools(agent.Tools.Clone()) subagentManager.SetTools(agent.Tools.Clone())
currentAgentID := agentID
if spawnEnabled { if spawnEnabled {
spawnTool := tools.NewSpawnTool(subagentManager) spawnTool := tools.NewSpawnTool(subagentManager)
spawnTool.SetSpawner(NewSubTurnSpawner(al)) spawnTool.SetSpawner(NewSubTurnSpawner(al))
currentAgentID := agentID
spawnTool.SetAllowlistChecker(func(targetAgentID string) bool { spawnTool.SetAllowlistChecker(func(targetAgentID string) bool {
return registry.CanSpawnSubagent(currentAgentID, targetAgentID) return registry.CanSpawnSubagent(currentAgentID, targetAgentID)
}) })