Add config for adaptive thinking Fixes #5236
| @@ -300,7 +300,7 @@ claude: | |||
| 300 | # Otherwise, you'll just waste money on cache misses. | 300 | # Otherwise, you'll just waste money on cache misses. |
| 301 | enableSystemPromptCache: false | 301 | enableSystemPromptCache: false |
| 302 | # Enables caching of the message history at depth (if supported). | 302 | # Enables caching of the message history at depth (if supported). |
| 303 | # https://docs.anthropic.com/en/docs/build-with-claude/prompt-caching | 303 | # https://platform.claude.com/docs/en/build-with-claude/prompt-caching |
| 304 | # -- IMPORTANT! -- | 304 | # -- IMPORTANT! -- |
| 305 | # Use with caution. Behavior may be unpredictable and no guarantees can or will be made. | 305 | # Use with caution. Behavior may be unpredictable and no guarantees can or will be made. |
| 306 | # Set to an integer to specify the desired depth. 0 (which does NOT include the prefill) | 306 | # Set to an integer to specify the desired depth. 0 (which does NOT include the prefill) |
| @@ -311,6 +311,10 @@ claude: | |||
| 311 | ## 5m: base price x 1.25 | 311 | ## 5m: base price x 1.25 |
| 312 | ## 1h: base price x 2 | 312 | ## 1h: base price x 2 |
| 313 | extendedTTL: false | 313 | extendedTTL: false |
| 314 | # Enables adaptive thinking for supported models (Opus 4.6+). | ||
| 315 | # Disable to enforce legacy thinking mode (with thinking budget). | ||
| 316 | # https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking | ||
| 317 | enableAdaptiveThinking: true | ||
| 314 | # -- GOOGLE GEMINI API CONFIGURATION -- | 318 | # -- GOOGLE GEMINI API CONFIGURATION -- |
| 315 | gemini: | 319 | gemini: |
| 316 | # API endpoint version ("v1beta" or "v1alpha") | 320 | # API endpoint version ("v1beta" or "v1alpha") |
| @@ -97,6 +97,7 @@ const cachingAtDepth = (() => { | |||
| 97 | const value = getConfigValue('claude.cachingAtDepth', -1, 'number'); | 97 | const value = getConfigValue('claude.cachingAtDepth', -1, 'number'); |
| 98 | return Number.isInteger(value) && value >= 0 ? value : -1; | 98 | return Number.isInteger(value) && value >= 0 ? value : -1; |
| 99 | })(); | 99 | })(); |
| 100 | const enableAdaptiveThinking = getConfigValue('claude.enableAdaptiveThinking', true, 'boolean'); | ||
| 100 | 101 | ||
| 101 | /** | 102 | /** |
| 102 | * Cache for cacheable (writing) OpenRouter model IDs. | 103 | * Cache for cacheable (writing) OpenRouter model IDs. |
| @@ -228,7 +229,7 @@ async function sendClaudeRequest(request, response) { | |||
| 228 | const isLimitedSampling = /^claude-(opus-4-1|sonnet-4-5|haiku-4-5|opus-4-5|opus-4-6|sonnet-4-6)/.test(request.body.model); | 229 | const isLimitedSampling = /^claude-(opus-4-1|sonnet-4-5|haiku-4-5|opus-4-5|opus-4-6|sonnet-4-6)/.test(request.body.model); |
| 229 | const useVerbosity = /^claude-(opus-4-5|opus-4-6|sonnet-4-6)/.test(request.body.model); | 230 | const useVerbosity = /^claude-(opus-4-5|opus-4-6|sonnet-4-6)/.test(request.body.model); |
| 230 | const noPrefillModel = /^claude-(opus-4-6|sonnet-4-6)/.test(request.body.model); | 231 | const noPrefillModel = /^claude-(opus-4-6|sonnet-4-6)/.test(request.body.model); |
| 231 | const isAdaptiveModel = /^claude-(opus-4-6|sonnet-4-6)/.test(request.body.model); | 232 | const isAdaptiveModel = enableAdaptiveThinking && /^claude-(opus-4-6|sonnet-4-6)/.test(request.body.model); |
| 232 | let fixThinkingPrefill = false; | 233 | let fixThinkingPrefill = false; |
| 233 | // Add custom stop sequences | 234 | // Add custom stop sequences |
| 234 | const stopSequences = []; | 235 | const stopSequences = []; |