From cfbe0fbd3995b5cf99c99d49c40738658ef7e4b6 Mon Sep 17 00:00:00 2001 From: jhfnetboy Date: Sun, 15 Mar 2026 21:17:26 +0700 Subject: [PATCH 1/2] fix: support adaptive thinking type and fix beta header handling 1. Add ThinkingConfigAdaptive to the request validation schema to support Claude 4-6+ models that use thinking: {"type": "adaptive"}. 2. Fix anthropic-beta header handling: use minimal required tags (claude-code-20250219, oauth-2025-04-20) and block CLI fallback headers from overwriting them. The fallback data included tags like fine-grained-tool-streaming-2025-05-14 that triggered "long context beta not available" errors for some subscriptions. Co-Authored-By: Claude Opus 4.6 (1M context) --- ccproxy/llms/models/anthropic.py | 9 ++++++++- ccproxy/plugins/claude_api/adapter.py | 9 ++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/ccproxy/llms/models/anthropic.py b/ccproxy/llms/models/anthropic.py index a5b7186e..4544fd84 100644 --- a/ccproxy/llms/models/anthropic.py +++ b/ccproxy/llms/models/anthropic.py @@ -352,8 +352,15 @@ class ThinkingConfigDisabled(ThinkingConfigBase): type: Literal["disabled"] = Field(default="disabled", alias="type") +class ThinkingConfigAdaptive(ThinkingConfigBase): + """Configuration for adaptive thinking (Claude 4-6+).""" + + type: Literal["adaptive"] = Field(default="adaptive", alias="type") + + ThinkingConfig = Annotated[ - ThinkingConfigEnabled | ThinkingConfigDisabled, Field(discriminator="type") + ThinkingConfigEnabled | ThinkingConfigDisabled | ThinkingConfigAdaptive, + Field(discriminator="type"), ] diff --git a/ccproxy/plugins/claude_api/adapter.py b/ccproxy/plugins/claude_api/adapter.py index 94a68b25..b012e1c9 100644 --- a/ccproxy/plugins/claude_api/adapter.py +++ b/ccproxy/plugins/claude_api/adapter.py @@ -85,15 +85,14 @@ async def prepare_provider_request( # Always set Authorization from OAuth-managed access token filtered_headers["authorization"] = f"Bearer {token_value}" - # PATCH: Add Computer Use beta headers for Anthropic API - # These are required for browser automation tools to work + # Minimal beta tags required for OAuth-based Claude Code auth filtered_headers["anthropic-version"] = "2023-06-01" - filtered_headers["anthropic-beta"] = "computer-use-2025-01-24" + filtered_headers["anthropic-beta"] = "claude-code-20250219,oauth-2025-04-20" - # Add CLI headers if available, but never allow overriding auth + # Add CLI headers if available, but never allow overriding auth or beta cli_headers = self._collect_cli_headers() if cli_headers: - blocked_overrides = {"authorization", "x-api-key"} + blocked_overrides = {"authorization", "x-api-key", "anthropic-beta"} for key, value in cli_headers.items(): lk = key.lower() if lk in blocked_overrides: From fafe783ace33678b7eb451eb18a06ea992cf0f32 Mon Sep 17 00:00:00 2001 From: Caddy Glow Date: Thu, 19 Mar 2026 20:58:47 +0100 Subject: [PATCH 2/2] feat(anthropic): add optional display field to adaptive thinking config Support summarized/omitted display modes for adaptive thinking responses. --- ccproxy/llms/models/anthropic.py | 1 + 1 file changed, 1 insertion(+) diff --git a/ccproxy/llms/models/anthropic.py b/ccproxy/llms/models/anthropic.py index 4544fd84..34da760b 100644 --- a/ccproxy/llms/models/anthropic.py +++ b/ccproxy/llms/models/anthropic.py @@ -356,6 +356,7 @@ class ThinkingConfigAdaptive(ThinkingConfigBase): """Configuration for adaptive thinking (Claude 4-6+).""" type: Literal["adaptive"] = Field(default="adaptive", alias="type") + display: Literal["summarized", "omitted"] | None = None ThinkingConfig = Annotated[