fix: forward anthropic-beta header in cache-warmer to support beta-gated body fields#357
Merged
Merged
Conversation
…ted body fields
Cache-warmer was getting 400 errors ('context_management: Extra inputs
are not permitted') because the stored request body contained beta-gated
fields but the warmup request was sent without the anthropic-beta header.
Store the anthropic-beta header from each real request on SessionState
and forward it in executeWarmup(), so any beta-gated body fields are
accepted upstream. The header is cleared when absent to avoid forwarding
a stale value after the client stops sending it.
864aa18 to
27a7fcc
Compare
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
context_management: Extra inputs are not permitted) because stored request bodies contained beta-gated fields but warmup requests were sent without theanthropic-betaheaderlastAnthropicBetaonSessionStatefrom each real request and forward it inexecuteWarmup(), so any beta-gated body fields (current and future) are accepted upstreamprepareAnthropicWarmupBodydoes not strip beta-gated fields likecontext_managementfrom the warmup bodyChanges
packages/gateway/src/translate/types.tslastAnthropicBeta?: stringtoSessionStatepackages/gateway/src/pipeline.tsanthropic-betaheader onto session state each turnpackages/gateway/src/cache-warmer.tsstate.lastAnthropicBetaas header inexecuteWarmup()packages/gateway/test/cache-warmer.test.tsNote
The broader
metadatapassthrough inbuildAnthropicRequest()(spreads all unknown body fields back into the upstream request) remains unchanged. This PR scopes the fix to the cache-warmer header gap only. Non-beta unknown fields that Anthropic rejects would need a separate allowlist/blocklist approach.