Repository navigation
feat(llm-client): allow forwarding all Anthropic beta headers - #940
ting-hong-shieh wants to merge 1 commit into
Conversation
Signed-off-by: Ting-Hong Shieh <shiehharry@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (9)
Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 11 remain after this review. WalkthroughThe client backend now supports OAuth-filtered or full forwarding of caller-supplied Anthropic beta headers. Runner configuration exposes the policy for Anthropic Messages clients with forwarded authentication. Tests and documentation cover the option and its request behavior. ChangesAnthropic beta forwarding
Priority: ➖ Normal Estimated code review effort: 3 (Moderate) | ~25 minutes Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to No actionable merge-blocking issue is identified; the change is mergeable after normal checks. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 68.42% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 19 functions across 7 files. (2 skipped: 2 unsupported.)
A rabbit checks the headers twice, Comment |
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
1df1dd7d: Rust workspace 927 passed, 1 ignored; prefill-router 70 passed; Python 187 passed, 2 deselected, 2 subtests passed. Formatting, workspace Clippy, prefill Clippy, Ruff, mypy, strict documentation build, and diff checks passed.Tests use local mocks. Live Anthropic acceptance and a Claude subscription session were not tested.
Commands:
cargo fmt --all --check;cargo clippy --workspace --all-targets --locked -- -D warnings;cargo test --workspace --locked; feature Clippy forswitchyard-serverand tests forswitchyard-runnerwith--features prefill-router --locked;uv run --no-sync ruff check .;uv run --no-sync mypy switchyard;uv run --no-sync pytest tests/ -v -m "not integration";make -C docs publish.Summary by CodeRabbit
"all"preserves all caller-supplied values, including repeated headers. This option requires Anthropic Messages format and authentication forwarding.