fix(tools): forward request options headers in BetaToolRunner compaction calls#962
Open
Scottcjn wants to merge 1 commit intoanthropics:mainfrom
Open
fix(tools): forward request options headers in BetaToolRunner compaction calls#962Scottcjn wants to merge 1 commit intoanthropics:mainfrom
Scottcjn wants to merge 1 commit intoanthropics:mainfrom
Conversation
…n BetaToolRunner The compaction call in BetaToolRunner's checkAndCompact() was passing only a hardcoded x-stainless-helper header, dropping any user-provided headers from the toolRunner request options. This merges the stored #options headers with the compaction header using buildHeaders, ensuring custom headers persist across all API calls in the tool-use loop. Co-Authored-By: Claude Opus 4.6 (1M context) <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
BetaToolRunner.#checkAndCompact()dropping user-provided request options headers when making the compaction API call{ headers: { 'x-stainless-helper': 'compaction' } }, discarding any headers fromthis.#optionsthat were provided viatoolRunner(params, options)buildHeaders(), consistent with how the main loop calls on lines 195/202 already passthis.#optionsWhat changed
src/lib/tools/BetaToolRunner.ts(1 line change):tests/lib/tools/ToolRunner.test.ts(2 new tests):forwards custom headers on every API call across tool-use turns— verifies request-level headers fromtoolRunner(params, { headers })persist on follow-up callsforwards defaultHeaders on every API call across tool-use turns— verifies client-leveldefaultHeaderspersist across the tool-use loopTest plan
npx jest tests/lib/)npx tsc -p tsconfig.json --noEmit)🤖 Generated with Claude Code