feat(agent): wire delegate tool registration for multi-agent setups
Register the delegate tool in registerSharedTools when multiple agents are configured. Gated independently from the subagent tool — delegate uses SubTurn directly and does not depend on SubagentManager. Self-delegation is prevented by injecting the current agent ID. Permission is enforced via CanSpawnSubagent (reuses allow_agents config). Single-agent setups are unaffected: the tool is not registered when only one agent exists in the registry. Ref: #2148
This commit is contained in:
parent
0ff78fa53f
commit
039f35563e
1 changed files with 14 additions and 0 deletions
|
|
@ -440,6 +440,20 @@ func registerSharedTools(
|
|||
} else if (spawnEnabled || spawnStatusEnabled) && !cfg.Tools.IsToolEnabled("subagent") {
|
||||
logger.WarnCF("agent", "spawn/spawn_status tools require subagent to be enabled", nil)
|
||||
}
|
||||
|
||||
// Register delegate tool for multi-agent setups.
|
||||
// Delegation uses the SubTurn mechanism directly (not SubagentManager),
|
||||
// so it does not depend on the subagent tool being enabled.
|
||||
if cfg.Tools.IsToolEnabled("delegate") && len(registry.ListAgentIDs()) > 1 {
|
||||
delegateTool := tools.NewDelegateTool()
|
||||
delegateTool.SetSpawner(NewSubTurnSpawner(al))
|
||||
currentAgentID := agentID
|
||||
delegateTool.SetSelfAgentID(currentAgentID)
|
||||
delegateTool.SetAllowlistChecker(func(targetAgentID string) bool {
|
||||
return registry.CanSpawnSubagent(currentAgentID, targetAgentID)
|
||||
})
|
||||
agent.Tools.Register(delegateTool)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue