Skip to content

fix: propagate defaultHeaders to sub-clients in toolRunner#927

Open
abdelhadi703 wants to merge 1 commit intoanthropics:mainfrom
abdelhadi703:fix/tool-runner-default-headers
Open

fix: propagate defaultHeaders to sub-clients in toolRunner#927
abdelhadi703 wants to merge 1 commit intoanthropics:mainfrom
abdelhadi703:fix/tool-runner-default-headers

Conversation

@abdelhadi703
Copy link

Summary

Fix toolRunner dropping defaultHeaders on follow-up requests. The Messages sub-client doesn't inherit custom headers from the parent client.

  • Accept an optional options parameter in the ToolRunner constructor (matching BetaToolRunner)
  • Forward options (including headers) to client.beta.messages.create() and client.beta.messages.stream() in the tool execution loop
  • Add BetaToolRunnerRequestOptions type export

Fixes #922

Changes

  • src/lib/tools/ToolRunner.ts: Propagate defaultHeaders from parent client to sub-clients in tool runner flow

Test plan

  • TypeScript compilation passes (tsc --noEmit)
  • Existing ToolRunner.test.ts tests pass
  • Verify that defaultHeaders (e.g. anthropic-beta) are present on follow-up requests in the tool execution loop

🤖 Generated with Claude Code

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>
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.

toolRunner drops defaultHeaders on follow-up requests (breaks proxy/gateway setups)

1 participant