Skip to content

fix(router): strip beta body fields for Vertex AI rawPredict routes#1742

Closed
stbenjam wants to merge 1 commit into
NVIDIA:mainfrom
stbenjam:fix/vertex-strip-beta-body-fields
Closed

fix(router): strip beta body fields for Vertex AI rawPredict routes#1742
stbenjam wants to merge 1 commit into
NVIDIA:mainfrom
stbenjam:fix/vertex-strip-beta-body-fields

Conversation

@stbenjam

@stbenjam stbenjam commented Jun 4, 2026

Copy link
Copy Markdown

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

  • Add VERTEX_ANTHROPIC_ALLOWED_BODY_FIELDS allowlist of stable Anthropic Messages API body fields accepted by Vertex AI rawPredict
  • After stripping model from the body on Vertex rawPredict routes, also retain() only fields in the allowlist — any beta or unknown fields are
    removed
  • Add two unit tests: vertex_ai_body_strips_beta_feature_fields and standard_anthropic_body_preserves_beta_feature_fields

Testing

  • mise run pre-commit passes
  • Unit tests added/updated
  • E2E tests added/updated (if applicable)
  • Manual end-to-end verification: ran Claude Code inside an OpenShell sandbox with a Vertex AI provider — confirmed it now works without
    CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1, which was previously required as a client-side workaround

Checklist

  • Follows Conventional Commits
  • Commits are signed off (DCO)
  • Architecture docs updated (if applicable)

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>
@copy-pr-bot

copy-pr-bot Bot commented Jun 4, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

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:

  1. Open a Vouch Request discussion.
  2. Describe what you want to change and why.
  3. Write in your own words — do not have an AI generate the request.
  4. A maintainer will comment /vouch if approved.
  5. Once vouched, open a new PR (preferred) or reopen this one after a few minutes.

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

All contributors have signed the DCO ✍️ ✅
Posted by the DCO Assistant Lite bot.

@github-actions github-actions Bot closed this Jun 4, 2026
@stbenjam

stbenjam commented Jun 4, 2026

Copy link
Copy Markdown
Author

I have read the DCO document and I hereby sign the DCO.

@stbenjam

stbenjam commented Jun 4, 2026

Copy link
Copy Markdown
Author

recheck

@stbenjam

stbenjam commented Jun 4, 2026

Copy link
Copy Markdown
Author

I think @maxamillion has a better solution coming for this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant