Skip to content

fix(subagent): ensure spawned subagents receive tools (#1713)#1717

Open
darrenzeng2025 wants to merge 1 commit intosipeed:mainfrom
darrenzeng2025:fix/1713-subagent-tools
Open

fix(subagent): ensure spawned subagents receive tools (#1713)#1717
darrenzeng2025 wants to merge 1 commit intosipeed:mainfrom
darrenzeng2025:fix/1713-subagent-tools

Conversation

@darrenzeng2025
Copy link
Contributor

Summary

Fix #1713: Subagents spawned via spawn tool have no tools

Problem

The spawn tool creates subagents that were not receiving any tools, causing API requests to lack the tools field. This happened because SubagentManager was initialized with an empty ToolRegistry instead of the agent's actual tools.

Root Cause

In pkg/agent/loop.go, the registerSharedTools() function created a SubagentManager but never called SetTools() to pass the agent's tool registry:

subagentManager := tools.NewSubagentManager(provider, agent.Model, agent.Workspace)
subagentManager.SetLLMOptions(agent.MaxTokens, agent.Temperature)
// Missing: subagentManager.SetTools(agent.Tools)

Solution

Added the missing SetTools() call to pass the agent's tool registry to the subagent manager:

subagentManager.SetTools(agent.Tools)

Changes

  1. pkg/agent/loop.go: Added subagentManager.SetTools(agent.Tools) in registerSharedTools()
  2. pkg/tools/subagent_tool_test.go: Added tests to verify SetTools behavior:
    • TestSubagentManager_SetTools: Verifies tools are properly passed
    • TestSubagentManager_SetTools_NilRegistry: Tests nil handling
    • TestSubagentManager_DefaultToolsNotNil: Verifies default initialization

Testing

The fix ensures that spawned subagents now have access to the same tools as the parent agent, allowing proper tool execution in the subagent's RunToolLoop.

Fix sipeed#1713: Subagents spawned via spawn tool have no tools

The issue was that SubagentManager was initialized with an empty
ToolRegistry instead of the agent's actual tools. This caused
spawned subagents to have no tools available during execution.

Changes:
- In registerSharedTools(), call subagentManager.SetTools(agent.Tools)
  to pass the agent's tool registry to the subagent manager
- Add tests to verify SetTools behavior and default initialization

The fix ensures that when a subagent is spawned, it has access to
the same tools as the parent agent, allowing proper tool execution
in the subagent's RunToolLoop.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Subagents spawned via spawn tool have no tools

1 participant