fix(ai): removed 1M context beta from Anthropic headers

- Sending context-1m-2025-08-07 caused OAuth requests without long-context credits to fail with 429, breaking Sonnet.
- Dropped the beta from agent, OAuth discovery, and usage-API headers.
This commit is contained in:
can1357
2026-06-04 13:41:58 +02:00
parent f6fca1f5cd
commit 10be5ddb54
6 changed files with 8 additions and 6 deletions
+4
View File
@@ -2,6 +2,10 @@
## [Unreleased]
### Fixed
- Removed the `context-1m-2025-08-07` (1M long-context) beta from the Anthropic agent request headers, the OAuth model-discovery header, and the Claude usage-API header. Sending it caused subscription/OAuth requests without long-context credits to fail with `429 Usage credits are required for long context requests`, breaking Sonnet. The remaining betas are unchanged.
## [15.9.0] - 2026-06-04
### Fixed
@@ -15,7 +15,7 @@ import { createBundledReferenceMap, createReferenceResolver } from "./bundled-re
const MODELS_DEV_URL = "https://models.dev/api.json";
const ANTHROPIC_BASE_URL = "https://api.anthropic.com/v1";
const ANTHROPIC_OAUTH_BETA =
"claude-code-20250219,oauth-2025-04-20,context-1m-2025-08-07,interleaved-thinking-2025-05-14,redact-thinking-2026-02-12,context-management-2025-06-27,prompt-caching-scope-2026-01-05,mid-conversation-system-2026-04-07,advanced-tool-use-2025-11-20,effort-2025-11-24,extended-cache-ttl-2025-04-11";
"claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,redact-thinking-2026-02-12,context-management-2025-06-27,prompt-caching-scope-2026-01-05,mid-conversation-system-2026-04-07,advanced-tool-use-2025-11-20,effort-2025-11-24,extended-cache-ttl-2025-04-11";
export interface ModelsDevModel {
id?: string;
-1
View File
@@ -132,7 +132,6 @@ const claudeCodeUtilityBetaDefaults = [
const claudeCodeAgentBetaDefaults = [
"claude-code-20250219",
"oauth-2025-04-20",
"context-1m-2025-08-07",
"interleaved-thinking-2025-05-14",
"context-management-2025-06-27",
"prompt-caching-scope-2026-01-05",
+1 -1
View File
@@ -22,7 +22,7 @@ const CLAUDE_HEADERS = {
accept: "application/json, text/plain, */*",
"accept-encoding": "gzip, compress, deflate, br",
"anthropic-beta":
"claude-code-20250219,oauth-2025-04-20,context-1m-2025-08-07,interleaved-thinking-2025-05-14,redact-thinking-2026-02-12,context-management-2025-06-27,prompt-caching-scope-2026-01-05,mid-conversation-system-2026-04-07,advanced-tool-use-2025-11-20,effort-2025-11-24,extended-cache-ttl-2025-04-11",
"claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,redact-thinking-2026-02-12,context-management-2025-06-27,prompt-caching-scope-2026-01-05,mid-conversation-system-2026-04-07,advanced-tool-use-2025-11-20,effort-2025-11-24,extended-cache-ttl-2025-04-11",
"content-type": "application/json",
"user-agent": "claude-cli/2.1.160 (external, cli)",
connection: "keep-alive",
+2 -2
View File
@@ -154,7 +154,7 @@ describe("Anthropic request fingerprint alignment", () => {
expect(headers["X-Claude-Code-Session-Id"]).toBe(sessionId);
expect(headers["x-client-request-id"]).toMatch(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/);
expect(headers["Anthropic-Beta"]).toBe(
"claude-code-20250219,oauth-2025-04-20,context-1m-2025-08-07,interleaved-thinking-2025-05-14,context-management-2025-06-27,prompt-caching-scope-2026-01-05,mid-conversation-system-2026-04-07,advanced-tool-use-2025-11-20,effort-2025-11-24,extended-cache-ttl-2025-04-11",
"claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,context-management-2025-06-27,prompt-caching-scope-2026-01-05,mid-conversation-system-2026-04-07,advanced-tool-use-2025-11-20,effort-2025-11-24,extended-cache-ttl-2025-04-11",
);
});
@@ -188,7 +188,7 @@ describe("Anthropic request fingerprint alignment", () => {
const hidden = buildAnthropicClientOptions({ ...baseArgs, thinkingDisplay: "omitted" });
expect(hidden.defaultHeaders["Anthropic-Beta"]).toBe(
"claude-code-20250219,oauth-2025-04-20,context-1m-2025-08-07,interleaved-thinking-2025-05-14,redact-thinking-2026-02-12,context-management-2025-06-27,prompt-caching-scope-2026-01-05,mid-conversation-system-2026-04-07,advanced-tool-use-2025-11-20,effort-2025-11-24,extended-cache-ttl-2025-04-11",
"claude-code-20250219,oauth-2025-04-20,interleaved-thinking-2025-05-14,redact-thinking-2026-02-12,context-management-2025-06-27,prompt-caching-scope-2026-01-05,mid-conversation-system-2026-04-07,advanced-tool-use-2025-11-20,effort-2025-11-24,extended-cache-ttl-2025-04-11",
);
const hiddenUtility = buildAnthropicClientOptions({
@@ -82,7 +82,6 @@ describe("claude usage request headers", () => {
const betaTokens = beta?.split(",").map(tokenValue => tokenValue.trim()) ?? [];
expect(betaTokens).toContain("claude-code-20250219");
expect(betaTokens).toContain("oauth-2025-04-20");
expect(betaTokens).toContain("context-1m-2025-08-07");
expect(betaTokens).toContain("interleaved-thinking-2025-05-14");
expect(betaTokens).toContain("redact-thinking-2026-02-12");
expect(betaTokens).toContain("context-management-2025-06-27");