fix(supervisor): add useToolHandler to fix streaming with SupervisorAgent#444
Open
guoyangzhen wants to merge 3 commits into2FastLabs:mainfrom
Open
fix(supervisor): add useToolHandler to fix streaming with SupervisorAgent#444guoyangzhen wants to merge 3 commits into2FastLabs:mainfrom
guoyangzhen wants to merge 3 commits into2FastLabs:mainfrom
Conversation
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.
Problem
SupervisorAgent with streaming enabled crashes with:
Reported in #252. When
SupervisorAgentsets up the lead agent'stoolConfiginconfigureSupervisorTools(), it only providestoolandtoolMaxRecursions— missinguseToolHandler. When the lead agent (BedrockLLMAgent or AnthropicAgent) processes a streaming response containingtool_useblocks, the fallback handler referencesthis.toolConfig.useToolHandlerwhich isundefined.Root Cause
The fallback handler in both
BedrockLLMAgentandAnthropicAgent(streaming and non-streaming paths) has a bug:When
useToolHandleris not set AND theinstanceof AgentToolscheck fails (can happen with different module instances), the code callsundefined.Fix
Primary —
supervisorAgent.ts: Add properuseToolHandlerto the toolConfig that delegates toAgentTools.toolHandlerwith the required getter methods. This ensures correct tool dispatch for both streaming and non-streaming.Secondary —
bedrockLLMAgent.tsandanthropicAgent.ts: Replace the danglingthis.toolConfig.useToolHandlerreference in the fallback handler with a clear error message.Testing