Skip to content

fix(anthropic): preserve required fallback beta with custom headers - #158300

Merged
RomneyDa merged 1 commit into
mainfrom
fix/anthropic-custom-beta-headers
Sep 25, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
fix/anthropic-custom-beta-headers

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes Anthropic API-key turns failing with HTTP 400 (fallbacks: Extra inputs are not permitted) when a custom anthropicBeta or beta header replaces the required server-side fallback beta. Found during live validation of #157595; this is a separate, preexisting failure.

User Impact

Users can keep custom Anthropic betas enabled on direct API-key requests without breaking otherwise valid turns. No configuration migration is needed.

Why This Change Was Made

Derive the required fallback beta from the final request payload in the existing shared request-policy owner, after custom headers and payload hooks. Both SDK and native transports use it. OAuth, proxy, and injected-client exclusions remain in place.

Evidence

  • Local live before/after through pnpm openclaw --profile ... agent --local, isolated state, stored API-key profile from 1Password, no provider credential environment variables, real https://api.anthropic.com/v1/messages endpoint. Model: anthropic/claude-opus-5-5; custom beta: files-api-2025-04-14.
    • Before (f13c49ca203): HTTP 400, fallbacks: Extra inputs are not permitted; payload contained fallbacks: "default" but outgoing header omitted its required beta.
    • After: HTTP 200, response LIVE_OK, normal stop termination, 3.023 s agent turn. Payload still contains fallbacks: "default"; outgoing header includes both the custom files beta and server-side-fallback-2026-07-01. Native OpenClaw harness and stored-profile credential provenance confirmed.
  • Four added regression cases failed before the production fix and passed after it. Shared cases cover model and request beta overrides in both adapters; existing OAuth/proxy exclusion cases remain green.
  • pnpm test packages/ai/src/providers/anthropic.test.ts --maxWorkers=1: 110 passed, 2.71 s wall.
  • pnpm test packages/ai/src/transports/anthropic-transport-stream.test.ts --maxWorkers=1: 143 passed, 2.58 s wall. Shared test-support module is exercised by these suites.
  • git diff --check and node scripts/check-changed.mjs passed, including formatting, production and all 25 core-test typecheck graphs, lint, dead-export scan, import-cycle checks, and repository guards.
  • Independent Codex autoreview: scoped-clean at P0–P2.
  • CI run is attached to 95bd8ca65ab; CI test timings are pending.

AI-assisted implementation and local verification; credentials and raw live logs are excluded from this PR.

@RomneyDa
RomneyDa marked this pull request as ready for review September 25, 2026 20:00
@clawsweeper

clawsweeper Bot commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@RomneyDa
RomneyDa enabled auto-merge (squash) September 25, 2026 20:01
@RomneyDa
RomneyDa merged commit 169da00 into main Sep 25, 2026
238 of 240 checks passed
@RomneyDa
RomneyDa deleted the fix/anthropic-custom-beta-headers branch September 25, 2026 20:19
roboclaw-bot added a commit that referenced this pull request Sep 25, 2026
Preserve authored selections, native thinking display and replay-bound cache
carriers. Raise the OAuth identity floor and retain required fallback betas
after custom headers and payload hooks without changing excluded transports.

Backport #156093: 5e5f9c2
Backport #156062: 2f10ac3
Backport #157662: d29ac12
Backport #158300: 169da00
The initial #155966 support is already inherited from the stable cut.

Co-authored-by: fuller-stack-dev <[email protected]>
Co-authored-by: Serg <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Co-authored-by: vyctorbrzezowski <[email protected]>
Co-authored-by: steipete <[email protected]>
Co-authored-by: jalehman <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant