diff --git a/pkg/agent/agent_init.go b/pkg/agent/agent_init.go index 7a9f5866b..78817dcf2 100644 --- a/pkg/agent/agent_init.go +++ b/pkg/agent/agent_init.go @@ -306,10 +306,10 @@ func registerSharedTools( // spawn_status which are added below — preventing recursive // subagent spawning. subagentManager.SetTools(agent.Tools.Clone()) + currentAgentID := agentID if spawnEnabled { spawnTool := tools.NewSpawnTool(subagentManager) spawnTool.SetSpawner(NewSubTurnSpawner(al)) - currentAgentID := agentID spawnTool.SetAllowlistChecker(func(targetAgentID string) bool { return registry.CanSpawnSubagent(currentAgentID, targetAgentID) })