From 96767b5d1a5c10b1890c332dfa5aee7cfa6a562a Mon Sep 17 00:00:00 2001 From: YeonGyu-Kim Date: Mon, 18 May 2026 12:36:45 +0900 Subject: [PATCH] fix(anthropic-effort): clamp pre-set effort=max for constrained providers regardless of variant Move the pre-set effort handling BEFORE the message.variant !== "max" early-return so that output.options.effort="max" set via session params or model-requirements fallback chains is always clamped to "high" on constrained providers (github-copilot, Anthropic OAuth), even when message.variant is not "max". This addresses the cubic violation from PR #3608 where the clamp block was gated behind the variant-based return. Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- src/hooks/anthropic-effort/hook.ts | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/hooks/anthropic-effort/hook.ts b/src/hooks/anthropic-effort/hook.ts index a545768d6..7d4eca99b 100644 --- a/src/hooks/anthropic-effort/hook.ts +++ b/src/hooks/anthropic-effort/hook.ts @@ -76,23 +76,35 @@ export function createAnthropicEffortHook() { const { agent, model, message } = input if (!model?.modelID || !model?.providerID) return if (isEffortUnsupportedModel(model.modelID)) return - if (message.variant !== "max") return if (!isClaudeProvider(model.providerID, model.modelID)) return if (shouldSkipForInternalAgent(agent?.name)) return - if (output.options.effort !== undefined) return const opus = isOpusModel(model.modelID) const constrained = isConstrainedProvider(model.providerID) + + if (output.options.effort !== undefined) { + if (output.options.effort === "max" && constrained) { + const clamped = clampVariant("max", opus, constrained) + output.options.effort = clamped + ;(message as { variant?: string }).variant = clamped + log("anthropic-effort: clamped pre-set effort max→high", { + sessionID: input.sessionID, + provider: model.providerID, + model: model.modelID, + reason: "constrained-provider", + }) + } + return + } + + if (message.variant !== "max") return + const clamped = clampVariant(message.variant, opus, constrained) output.options.effort = clamped const shouldOverrideMessageVariant = !opus || constrained if (shouldOverrideMessageVariant) { - // Override the variant so OpenCode doesn't pass "max" to the API. - // Non-Opus models cap at high; Anthropic OAuth (Claude Pro/Max) also - // caps at high even on Opus because the OAuth API only accepts - // low | medium | high. ;(message as { variant?: string }).variant = clamped log("anthropic-effort: clamped variant max→high", { sessionID: input.sessionID,