Repository navigation
feat(llm-client): allow forwarding all Anthropic beta headers - #940
ting-hong-shieh wants to merge 1 commit into
Conversation
|
Resolved the runner import conflict and integrated main Local validation passed: Rust workspace (1,109 passed, 1 ignored), prefill runner (82 passed), Python (198 passed, 2 integration tests deselected), Clippy, formatting, Ruff, mypy, and strict docs build. Tests used local mocks; live Anthropic acceptance was not tested. The latest CI, documentation, getting-started, and package-portability runs show |
|
@grahamking to provide feedback |
|
@ting-hong-shieh Meanwhile can you rebase this one please ? |
Signed-off-by: Ting-Hong Shieh <shiehharry@gmail.com>
d98ae71 to
907a4dc
Compare
|
Can you give some examples of those beta headers? |
|
Two documented non-OAuth examples are:
With OAuth-only forwarding, those values are stripped while the paired body fields remain. These are documented protocol examples, not live acceptance tests of this PR. The option remains opt-in so deployments whose upstream rejects particular betas can retain the current filtering. |
|
The values we're talking about are all in an HTTP We dropped that In #372 we started copying the On the one hand I don't want such a niche config setting, especially for something that could break Azure endpoints. On the other hand, we do want to support Claude's beta headers. What are your thoughts @ting-hong-shieh ? |
|
I'd prefer to avoid the extra setting by choosing the forwarding policy from the configured upstream URL:
That would address the direct-Anthropic case in #938 without changing the Azure forwarding policy. Custom reverse proxies would retain filtering under this approach; supporting them would need a separate decision. Would that fit the direction you want? If so, I can remove |
What
When
forward_auth = true, a caller can send beta-specific body fields while Switchyard drops theiranthropic-betavalues. Addforward_beta = "all"on ananthropic_messagesclient to forward the caller's beta header values unchanged, including repeated headers. Omitted or"oauth"settings keep the existing OAuth-only filtering.Why
Claude Code may pair request fields with experimental beta values. Dropping those values can cause upstream HTTP 400 responses. Closes #938.
Notes for reviewers
The policy is applied in the shared HTTP request path for completion and token-counting calls. TOML permits the field only for Anthropic Messages clients with auth forwarding enabled. Static
anthropic-betavalues inextra_headersremain rejected in both forwarding modes.The public Rust
HttpBackendConfigstruct gainsforward_beta. Downstream struct literals need to addforward_beta: Default::default()orForwardBeta::All. Existing TOML files need no edit. No body translation code changes.Validation at
d98ae71b, integrated with main9ddd4879:Live Anthropic acceptance and a Claude subscription session were not tested.
Summary by CodeRabbit
"all"preserves all caller-supplied values, including repeated headers. This option requires Anthropic Messages format and authentication forwarding.