fix: forward client headers in native passthrough mode#586
Open
zerray wants to merge 1 commit intodecolua:masterfrom
Open
fix: forward client headers in native passthrough mode#586zerray wants to merge 1 commit intodecolua:masterfrom
zerray wants to merge 1 commit intodecolua:masterfrom
Conversation
… flags In native passthrough (claude-to-claude), 9router was rebuilding request headers from static config + cached values, injecting extra anthropic-beta flags (e.g. token-efficient-tools) that the client never sent. This caused the upstream Claude API to behave differently, leading to unicode encoding anomalies in tool call arguments. Now in passthrough mode, the client's original headers are forwarded directly — only auth is swapped and oauth beta flag ensured. 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
anthropic-betaflags (e.g.token-efficient-tools-2026-03-28) to be injected into upstream API requests via the union merge logic inDefaultExecutor.buildHeaders, even though the client never sent themu8fd9instead of这inpartial_jsondeltas)Changes
open-sse/executors/base.jsbuildPassthroughHeaders()method that starts from the client's original headers, strips hop-by-hop headers, swaps auth credentials, and ensures theoauth-2025-04-20beta flag when using OAuthexecute()to acceptpassthroughandclientHeadersparams, usingbuildPassthroughHeaderswhen both are presentopen-sse/handlers/chatCore.jspassthroughflag andclientRawRequest.headerstoexecutor.execute()at both call sites (initial request + retry-after-refresh)Root cause
The static
Anthropic-Betaheader inproviders.jsincludes flags liketoken-efficient-tools-2026-03-28that are not present in Claude Code's own requests. The header merge logic (union of static + cached flags) injected these into every upstream request. With this fix, passthrough requests forward the client's exact headers — only auth is swapped.Test plan
cc/claude-opus-4-6passthrough: Chinese unicode characters now render correctly in tool call argumentsbuildHeaders()with static config as beforeoauth-2025-04-20beta flag injected automatically🤖 Generated with Claude Code