From 5fc126427c4fdd42b7589fa2e155bea9154807de Mon Sep 17 00:00:00 2001 From: diegosouzapw Date: Wed, 29 Apr 2026 09:54:52 -0300 Subject: [PATCH] fix(claude): respect client thinking/effort params to prevent forced quota drain (#1761) Previously, OmniRoute unconditionally injected thinking: {type: 'adaptive'} and output_config: {effort: 'high'} for Claude Opus 4.7 in Claude Code client requests. This caused Claude Max 5h quota to drain in ~15 minutes. Now checks the original client body: if thinking or output_config are explicitly set (even to null or a different value), the injection is skipped. Users can opt-out by sending thinking: null or output_config: {effort: 'low'}. --- open-sse/executors/base.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/open-sse/executors/base.ts b/open-sse/executors/base.ts index ada44b7279..84bfe76a8d 100644 --- a/open-sse/executors/base.ts +++ b/open-sse/executors/base.ts @@ -527,17 +527,25 @@ export class BaseExecutor { const supportsAdaptiveThinking = supportsXHighEffort("claude", model); - if (supportsAdaptiveThinking && !tb.thinking) { + // Fix #1761: Only inject adaptive thinking/high effort if the client didn't + // explicitly set these fields. This allows users to opt-out by sending + // `thinking: null` or `output_config: { effort: "low" }` to prevent forced + // quota drain on Claude Max accounts. + const originalBody = body as Record; + const clientExplicitThinking = originalBody?.thinking !== undefined; + const clientExplicitEffort = originalBody?.output_config !== undefined; + + if (supportsAdaptiveThinking && !tb.thinking && !clientExplicitThinking) { tb.thinking = { type: "adaptive" }; } - if (supportsAdaptiveThinking && !tb.context_management) { + if (supportsAdaptiveThinking && !tb.context_management && !clientExplicitThinking) { tb.context_management = { edits: [{ type: "clear_thinking_20251015", keep: "all" }], }; } - if (supportsAdaptiveThinking && !tb.output_config) { + if (supportsAdaptiveThinking && !tb.output_config && !clientExplicitEffort) { tb.output_config = { effort: "high" }; }