fix: propagate defaultHeaders to sub-clients in toolRunner#927
Open
abdelhadi703 wants to merge 1 commit intoanthropics:mainfrom
Open
fix: propagate defaultHeaders to sub-clients in toolRunner#927abdelhadi703 wants to merge 1 commit intoanthropics:mainfrom
abdelhadi703 wants to merge 1 commit intoanthropics:mainfrom
Conversation
The ToolRunner was not forwarding request options (including headers) to follow-up API calls in the tool execution loop. This caused defaultHeaders (e.g. anthropic-beta) set on the parent client to be dropped on subsequent requests. Accept an optional `options` parameter in the ToolRunner constructor and pass it through to `client.beta.messages.create()` and `client.beta.messages.stream()` calls, matching the behavior already present in BetaToolRunner. Fixes anthropics#922 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
toolRunnerdroppingdefaultHeaderson follow-up requests. TheMessagessub-client doesn't inherit custom headers from the parent client.optionsparameter in theToolRunnerconstructor (matchingBetaToolRunner)client.beta.messages.create()andclient.beta.messages.stream()in the tool execution loopBetaToolRunnerRequestOptionstype exportFixes #922
Changes
src/lib/tools/ToolRunner.ts: PropagatedefaultHeadersfrom parent client to sub-clients in tool runner flowTest plan
tsc --noEmit)ToolRunner.test.tstests passdefaultHeaders(e.g.anthropic-beta) are present on follow-up requests in the tool execution loop🤖 Generated with Claude Code