Add config for adaptive thinking Fixes #5236

3070cf26cd9c1bc10e47f32163afdc804a9e1add

Cohee <18619528+Cohee1207@users.noreply.github.com>

2 files changed, +7 -2Showing whitespace changes
default/config.yaml+5 -1
@@ -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: false301 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-caching303 # 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.25311 ## 5m: base price x 1.25
312 ## 1h: base price x 2312 ## 1h: base price x 2
313 extendedTTL: false313 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 --
315gemini:319gemini:
316 # API endpoint version ("v1beta" or "v1alpha")320 # API endpoint version ("v1beta" or "v1alpha")
src/endpoints/backends/chat-completions.js+2 -1
@@ -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})();
100const enableAdaptiveThinking = getConfigValue('claude.enableAdaptiveThinking', true, 'boolean');
100101
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 sequences234 // Add custom stop sequences
234 const stopSequences = [];235 const stopSequences = [];