fix(router): strip beta body fields for Vertex AI rawPredict routes#1742
Closed
stbenjam wants to merge 1 commit into
Closed
fix(router): strip beta body fields for Vertex AI rawPredict routes#1742stbenjam wants to merge 1 commit into
stbenjam wants to merge 1 commit into
Conversation
The gateway already strips the `anthropic-beta` header when routing to
Vertex AI rawPredict endpoints, but clients like Claude Code also send
matching top-level body fields for enabled betas (e.g.
`context_management`, `interleaved_thinking`). Vertex AI rejects these
with HTTP 400: "Extra inputs are not permitted".
Reproducer (inside an OpenShell sandbox with a Vertex AI provider):
ANTHROPIC_BASE_URL=https://inference.local \
ANTHROPIC_API_KEY=unused \
claude -p "Hi"
=> API Error: 400 context_management: Extra inputs are not permitted
A client-side workaround exists — setting
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 prevents Claude Code from
sending beta fields entirely — but this disables all experimental betas
including ones the user may want (e.g. extended thinking, structured
outputs). The fix belongs in the gateway so that clients work
transparently.
Add an allowlist of stable Anthropic Messages API body fields and strip
any unrecognized top-level field from the request body on Vertex AI
rawPredict routes. This complements the existing header stripping and
model field removal, ensuring the request body conforms to what Vertex
AI accepts.
The allowlist approach is preferred over mapping header values to body
field names because the Anthropic beta naming convention is inconsistent
(e.g. header `advanced-tool-use-2025-11-20` maps to body field
`tool_search`, not `advanced_tool_use`).
With this fix applied:
ANTHROPIC_BASE_URL=https://inference.local \
ANTHROPIC_API_KEY=unused \
claude -p "Say hello in one word"
=> Hello!
Assisted-by: Claude
Signed-off-by: Stephen Benjamin <stephen@redhat.com>
|
Thank you for your interest in contributing to OpenShell, @stbenjam. This project uses a vouch system for first-time contributors. Before submitting a pull request, you need to be vouched by a maintainer. To get vouched:
See CONTRIBUTING.md for details. |
|
All contributors have signed the DCO ✍️ ✅ |
Author
|
I have read the DCO document and I hereby sign the DCO. |
Author
|
recheck |
Author
|
I think @maxamillion has a better solution coming for this |
6 tasks
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
Strip Anthropic beta body fields (e.g. context_management, interleaved_thinking) from request bodies when routing to Vertex AI rawPredict endpoints.
The gateway already strips the anthropic-beta header for these routes, but clients like Claude Code also send matching top-level body fields that Vertex AI rejects with HTTP 400: "Extra inputs are not permitted".
Alternatives would be to just rely on
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1, but there's no guarantee this continues to work.Related Issue
N/A
Changes
removed
Testing
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1, which was previously required as a client-side workaround
Checklist