fix: merge SDK anthropic-beta headers with base endpoint betas#4945
Merged
TylerLeonhardt merged 1 commit intomainfrom Apr 3, 2026
Merged
fix: merge SDK anthropic-beta headers with base endpoint betas#4945TylerLeonhardt merged 1 commit intomainfrom
TylerLeonhardt merged 1 commit intomainfrom
Conversation
The ClaudeStreamingPassThroughEndpoint.getExtraHeaders() was overwriting the base endpoint's anthropic-beta header with the SDK's filtered betas instead of merging them. This caused context editing to fail because the context-management beta header (set by chatEndpoint based on config) was lost when the SDK sent its own anthropic-beta header. Now uses a Set to merge and deduplicate both sources of beta headers. Fixes microsoft/vscode#298471
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Claude Code “context_management: Extra inputs are not permitted” failures by ensuring the SDK-provided anthropic-beta header does not overwrite (but instead merges with) beta headers added by the base endpoint (e.g., context-management-2025-06-27 when context editing is enabled).
Changes:
- Merge base endpoint
anthropic-betavalues with SDK-provided, filtered betas using aSetfor deduplication. - Preserve config-driven betas while still filtering incoming SDK betas to supported values.
TylerLeonhardt
approved these changes
Apr 3, 2026
Member
TylerLeonhardt
left a comment
There was a problem hiding this comment.
This is fine for now, but it's not how I'd like it to work.
I want the Claude agent to be the only thing that adds Anthropic-related stuff (body/headers) to the request.
Let it decide how it wants to use the Messages API.
The exception would be any CAPI specific weirdness.
Contributor
Author
|
better fix with microsoft/vscode#308387 |
bhavyaus
added a commit
to microsoft/vscode
that referenced
this pull request
Apr 17, 2026
Callers can now opt into Anthropic features (context editing, tool search, etc.) by setting modelCapabilities on the request itself, as introduced in #308387. The base endpoint no longer needs to inject beta headers — the Claude agent controls its own headers. Reverts the merge logic from microsoft/vscode-copilot-chat#4945.
bhavyaus
added a commit
to microsoft/vscode
that referenced
this pull request
Apr 17, 2026
…nt (#310908) Callers can now opt into Anthropic features (context editing, tool search, etc.) by setting modelCapabilities on the request itself, as introduced in #308387. The base endpoint no longer needs to inject beta headers — the Claude agent controls its own headers. Reverts the merge logic from microsoft/vscode-copilot-chat#4945.
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.
Problem
When
contextEditing.modeis enabled (e.g.clear-tooluse), the Claude agent fails with:Root Cause
In
ClaudeStreamingPassThroughEndpoint.getExtraHeaders(), the SDK'santhropic-betaheader was overwriting the base endpoint's beta headers instead of merging with them.chatEndpoint.getExtraHeaders()addscontext-management-2025-06-27toanthropic-beta(driven by thecontextEditing.modeconfig)createMessagesRequestBodyaddscontext_managementto the request bodyanthropic-betaheader (which doesn't includecontext-management) replaces the base's valuecontext_managementin the body without the required beta header → 400 errorFix
Merge the SDK's filtered betas with the base endpoint's betas using a
Setto deduplicate, instead of overwriting.Fixes microsoft/vscode#298471