Skip to content

fix: set anthropic beta headers in vertex requests headers as well - #3585

Merged
akshaydeo merged 1 commit into
devfrom
05-19-fix_set_anthropic_beta_headers_in_vertex_requests_headers_as_well
May 19, 2026
Merged

fix: set anthropic beta headers in vertex requests headers as well#3585
akshaydeo merged 1 commit into
devfrom
05-19-fix_set_anthropic_beta_headers_in_vertex_requests_headers_as_well

Conversation

@TejasGhatte

@TejasGhatte TejasGhatte commented May 19, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds proper anthropic-beta header propagation for Vertex AI's Responses and ResponsesStream endpoints, ensuring beta feature headers are correctly filtered and applied when making Anthropic-on-Vertex requests.

Changes

  • Applied FilterBetaHeadersForProvider and MergeBetaHeaders logic to the Vertex Responses method, replacing the previous unconditional SetExtraHeaders behavior with explicit beta header setting or deletion.
  • Applied the same beta header logic to ResponsesStream, injecting the filtered beta headers into the request headers map before streaming begins.
  • Removed an unnecessary blank line in Responses after the bifrostErr check.
  • Removed redundant parentheses around a boolean condition in ChatCompletionStream.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

Send a request to the Vertex Responses or ResponsesStream endpoint using an Anthropic model that requires a beta header (e.g., a model requiring interleaved-thinking-20250522). Verify that the anthropic-beta header is correctly set in the outgoing request and that the response is successful.

go test ./...

Breaking changes

  • Yes
  • No

Related issues

Security considerations

No security implications. Changes are limited to header propagation logic for Vertex AI Anthropic requests.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e7ca6e4c-081b-4dc7-89e7-e9de0ab7f66a

📥 Commits

Reviewing files that changed from the base of the PR and between a75995b and 718f38c.

📒 Files selected for processing (1)
  • core/providers/vertex/vertex.go

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved header handling for the Vertex provider: beta headers are now computed from merged context/network extras, set as a comma-joined header when present, and removed when none remain.
  • Refactor

    • Simplified conditional logic to streamline branching and improve maintainability.

Walkthrough

The Vertex provider now explicitly filters merged network/context beta headers and sets or deletes anthropic.AnthropicBetaHeader in the Anthropic Responses flow. A redundant-parentheses cleanup was applied to the Gemini model check and a small context boundary was adjusted before extracting projectID and region.

Changes

Vertex Anthropic Beta Header Management

Layer / File(s) Summary
Anthropic beta header filtering in Responses
core/providers/vertex/vertex.go
Filters merged network + context extra headers for Vertex-scoped beta headers; sets anthropic.AnthropicBetaHeader to a comma-joined string when present, otherwise deletes the header (lines 1046–1051).
Minor cleanups and context adjustments
core/providers/vertex/vertex.go
Removes redundant parentheses from the Gemini model check (line 913) and adjusts a small boundary/context before projectID/region extraction in Anthropic Responses (line 1018).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • danpiths
  • akshaydeo

Poem

🐰 I hopped through headers, sharp and neat,
Trimmed beta strings to make them meet,
Brushed off a parenthesis, light and quick,
Adjusted a boundary, small but slick,
Vertex and Anthropic—my tidy little feat!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: setting anthropic beta headers in Vertex requests, matching the core modification in the changeset.
Description check ✅ Passed The description comprehensively covers the purpose, detailed changes, type, affected areas, testing instructions, breaking changes, and security considerations, matching the template structure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 05-19-fix_set_anthropic_beta_headers_in_vertex_requests_headers_as_well

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@TejasGhatte
TejasGhatte marked this pull request as ready for review May 19, 2026 08:07
@coderabbitai
coderabbitai Bot requested a review from danpiths May 19, 2026 08:08
coderabbitai[bot]
coderabbitai Bot previously approved these changes May 19, 2026
@greptile-apps

greptile-apps Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge — the change is a targeted header-propagation fix that follows the established pattern used by the direct Anthropic provider path.

The new beta-header block in Responses mirrors identical logic elsewhere in the codebase, operates on the same inputs, and is ordered correctly after SetExtraHeaders (which already excludes the beta header). ResponsesStream delegates to HandleAnthropicResponsesStream, which handles the header internally, so no parallel risk there. No data paths, auth flows, or external contracts are affected beyond header forwarding.

No files require special attention.

Important Files Changed

Filename Overview
core/providers/vertex/vertex.go Adds proper anthropic-beta header filtering and propagation in the Responses method; also removes unnecessary parentheses in ChatCompletionStream and a stray blank line. Changes follow the same FilterBetaHeadersForProvider + MergeBetaHeaders pattern used elsewhere in the codebase.

Reviews (2): Last reviewed commit: "fix: set anthropic beta headers in verte..." | Re-trigger Greptile

Comment thread core/providers/vertex/vertex.go Outdated
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


tejas ghatte seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

@TejasGhatte
TejasGhatte force-pushed the 05-19-fix_set_anthropic_beta_headers_in_vertex_requests_headers_as_well branch from a75995b to 718f38c Compare May 19, 2026 08:46
@coderabbitai
coderabbitai Bot requested a review from akshaydeo May 19, 2026 08:47

akshaydeo commented May 19, 2026

Copy link
Copy Markdown
Contributor

Merge activity

  • May 19, 10:34 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 19, 10:34 AM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo merged commit 4a42d35 into dev May 19, 2026
15 checks passed
@akshaydeo
akshaydeo deleted the 05-19-fix_set_anthropic_beta_headers_in_vertex_requests_headers_as_well branch May 19, 2026 10:34
akshaydeo pushed a commit that referenced this pull request May 20, 2026
…3585)

## Summary

This PR adds proper `anthropic-beta` header propagation for Vertex AI's `Responses` and `ResponsesStream` endpoints, ensuring beta feature headers are correctly filtered and applied when making Anthropic-on-Vertex requests.

## Changes

- Applied `FilterBetaHeadersForProvider` and `MergeBetaHeaders` logic to the Vertex `Responses` method, replacing the previous unconditional `SetExtraHeaders` behavior with explicit beta header setting or deletion.
- Applied the same beta header logic to `ResponsesStream`, injecting the filtered beta headers into the request headers map before streaming begins.
- Removed an unnecessary blank line in `Responses` after the `bifrostErr` check.
- Removed redundant parentheses around a boolean condition in `ChatCompletionStream`.

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [ ] Core (Go)
- [ ] Transports (HTTP)
- [x] Providers/Integrations
- [ ] Plugins
- [ ] UI (React)
- [ ] Docs

## How to test

Send a request to the Vertex `Responses` or `ResponsesStream` endpoint using an Anthropic model that requires a beta header (e.g., a model requiring `interleaved-thinking-20250522`). Verify that the `anthropic-beta` header is correctly set in the outgoing request and that the response is successful.

```sh
go test ./...
```

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

## Security considerations

No security implications. Changes are limited to header propagation logic for Vertex AI Anthropic requests.

## Checklist

- [ ] I read `docs/contributing/README.md` and followed the guidelines
- [ ] I added/updated tests where appropriate
- [ ] I updated documentation where needed
- [ ] I verified builds succeed (Go and UI)
- [ ] I verified the CI pipeline passes locally if applicable
@akshaydeo akshaydeo mentioned this pull request May 20, 2026
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.

3 participants