Skip to content

fix: forward anthropic-beta header in cache-warmer to support beta-gated body fields#357

Merged
BYK merged 1 commit into
mainfrom
fix/cache-warmer-forward-beta-header
May 16, 2026
Merged

fix: forward anthropic-beta header in cache-warmer to support beta-gated body fields#357
BYK merged 1 commit into
mainfrom
fix/cache-warmer-forward-beta-header

Conversation

@BYK
Copy link
Copy Markdown
Owner

@BYK BYK commented May 16, 2026

Summary

  • Cache-warmer was getting 400 errors (context_management: Extra inputs are not permitted) because stored request bodies contained beta-gated fields but warmup requests were sent without the anthropic-beta header
  • Store lastAnthropicBeta on SessionState from each real request and forward it in executeWarmup(), so any beta-gated body fields (current and future) are accepted upstream
  • Header is cleared when absent to avoid forwarding a stale value after the client stops sending it
  • Added regression test ensuring prepareAnthropicWarmupBody does not strip beta-gated fields like context_management from the warmup body

Changes

File Change
packages/gateway/src/translate/types.ts Add lastAnthropicBeta?: string to SessionState
packages/gateway/src/pipeline.ts Capture/clear anthropic-beta header onto session state each turn
packages/gateway/src/cache-warmer.ts Forward state.lastAnthropicBeta as header in executeWarmup()
packages/gateway/test/cache-warmer.test.ts Regression test: beta-gated fields preserved in warmup body

Note

The broader metadata passthrough in buildAnthropicRequest() (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.

…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.
@BYK BYK force-pushed the fix/cache-warmer-forward-beta-header branch from 864aa18 to 27a7fcc Compare May 16, 2026 11:29
@BYK BYK merged commit 7772118 into main May 16, 2026
7 checks passed
@BYK BYK deleted the fix/cache-warmer-forward-beta-header branch May 16, 2026 11:32
@craft-deployer craft-deployer Bot mentioned this pull request May 16, 2026
6 tasks
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