fix(subagent): ensure spawned subagents receive tools (#1713)#1717
Open
darrenzeng2025 wants to merge 1 commit intosipeed:mainfrom
Open
fix(subagent): ensure spawned subagents receive tools (#1713)#1717darrenzeng2025 wants to merge 1 commit intosipeed:mainfrom
darrenzeng2025 wants to merge 1 commit intosipeed:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix #1713: Subagents spawned via spawn tool have no tools
Problem
The
spawntool creates subagents that were not receiving any tools, causing API requests to lack thetoolsfield. This happened becauseSubagentManagerwas initialized with an emptyToolRegistryinstead of the agent's actual tools.Root Cause
In
pkg/agent/loop.go, theregisterSharedTools()function created aSubagentManagerbut never calledSetTools()to pass the agent's tool registry:Solution
Added the missing
SetTools()call to pass the agent's tool registry to the subagent manager:Changes
subagentManager.SetTools(agent.Tools)inregisterSharedTools()SetToolsbehavior:TestSubagentManager_SetTools: Verifies tools are properly passedTestSubagentManager_SetTools_NilRegistry: Tests nil handlingTestSubagentManager_DefaultToolsNotNil: Verifies default initializationTesting
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.