fix: forward Anthropic-Beta header to Anthropic provider#205
Merged
ssncferreira merged 1 commit intomainfrom Mar 6, 2026
Merged
fix: forward Anthropic-Beta header to Anthropic provider#205ssncferreira merged 1 commit intomainfrom
ssncferreira merged 1 commit intomainfrom
Conversation
dannykopping
approved these changes
Mar 6, 2026
| assert.Contains(t, err.Error(), "unmarshal request body") | ||
| }) | ||
|
|
||
| t.Run("Messages_ForwardsAnthropicBetaHeaderToUpstream", func(t *testing.T) { |
Collaborator
There was a problem hiding this comment.
Nit: AFAICS this is the only relevant sub-test.
Adding the others is a nice improvement, though.
Contributor
Author
There was a problem hiding this comment.
Yes, the others are not really testing the header logic. Should have been added in another PR, sorry about that
pawbana
approved these changes
Mar 6, 2026
| "github.com/coder/aibridge/internal/testutil" | ||
| ) | ||
|
|
||
| func TestAnthropic_CreateInterceptor(t *testing.T) { |
Contributor
There was a problem hiding this comment.
Those test look quite copy-pasty, eg. body in each test case looks the same or verification that interceptor was created without error.
Would it be possible to shorten them with table test approach?
Contributor
Author
There was a problem hiding this comment.
Probably, yes. I reused some from the Copilot tests, so we should probably update there as well.
ssncferreira
added a commit
that referenced
this pull request
Mar 6, 2026
(cherry picked from commit 1e9e0d8)
This was referenced Mar 6, 2026
ssncferreira
added a commit
to coder/coder
that referenced
this pull request
Mar 6, 2026
…fix (#22711) Bumps aibridge to include coder/aibridge#205 which forwards the Anthropic-Beta header to the upstream Anthropic API. Related to: * issue: coder/aibridge#192 * Internal Slack thread: https://codercom.slack.com/archives/C096PFVBZKN/p1772792545309049
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.

Description
AI Bridge drops client request headers when making upstream API calls through bridge routes. This causes failures when the client sends headers that correspond to features used in the request body. For example, Claude Code sends
Anthropic-Beta: context-managementalongside acontext_managementfield in the body. AI Bridge preserves the body but drops the header, causing Anthropic to reject the request.Rather than forwarding all client headers (addressed in #195), this PR takes a targeted approach by forwarding only known required headers for Anthropic, matching the same pattern used by the Copilot provider with
ExtraHeaders.Related to #192
Note: This is an intermediary fix. The full solution, forwarding all client headers to upstream providers, is tracked in #195. Related to internal Slack thread: https://codercom.slack.com/archives/C096PFVBZKN/p1772792545309049