refactor(agent): simplify delegate registration gate

Remove the IsToolEnabled("delegate") check — there is no "delegate"
entry in ToolsConfig, so the check was always true. The only real
gate is len(agents) > 1, which is the intended behavior: delegate
is auto-registered in multi-agent setups.

Ref: #2148
This commit is contained in:
xiaoen 2026-04-15 22:24:47 +08:00
parent 6db17b8211
commit 6ee66123f2

View file

@ -442,9 +442,10 @@ func registerSharedTools(
} }
// Register delegate tool for multi-agent setups. // Register delegate tool for multi-agent setups.
// Delegation uses the SubTurn mechanism directly (not SubagentManager), // Auto-enabled when multiple agents exist. Delegation uses the SubTurn
// so it does not depend on the subagent tool being enabled. // mechanism directly (not SubagentManager) and is independent of the
if cfg.Tools.IsToolEnabled("delegate") && len(registry.ListAgentIDs()) > 1 { // subagent tool.
if len(registry.ListAgentIDs()) > 1 {
delegateTool := tools.NewDelegateTool() delegateTool := tools.NewDelegateTool()
delegateTool.SetSpawner(NewSubTurnSpawner(al)) delegateTool.SetSpawner(NewSubTurnSpawner(al))
currentAgentID := agentID currentAgentID := agentID