fix(anthropic-effort): clamp variant against mutable request message
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { log, normalizeModelID } from "../../shared"
|
||||
|
||||
const OPUS_4_6_PATTERN = /claude-opus-4[-.]6/i
|
||||
const OPUS_PATTERN = /claude-opus/i
|
||||
|
||||
function isClaudeProvider(providerID: string, modelID: string): boolean {
|
||||
if (["anthropic", "google-vertex-anthropic", "opencode"].includes(providerID)) return true
|
||||
@@ -8,9 +8,9 @@ function isClaudeProvider(providerID: string, modelID: string): boolean {
|
||||
return false
|
||||
}
|
||||
|
||||
function isOpus46(modelID: string): boolean {
|
||||
function isOpusModel(modelID: string): boolean {
|
||||
const normalized = normalizeModelID(modelID)
|
||||
return OPUS_4_6_PATTERN.test(normalized)
|
||||
return OPUS_PATTERN.test(normalized)
|
||||
}
|
||||
|
||||
interface ChatParamsInput {
|
||||
@@ -54,7 +54,7 @@ export function createAnthropicEffortHook() {
|
||||
if (!isClaudeProvider(model.providerID, model.modelID)) return
|
||||
if (output.options.effort !== undefined) return
|
||||
|
||||
const opus = isOpus46(model.modelID)
|
||||
const opus = isOpusModel(model.modelID)
|
||||
const clamped = clampVariant(message.variant, opus)
|
||||
output.options.effort = clamped
|
||||
|
||||
|
||||
Reference in New Issue
Block a user