add anthropic/ provider prefix for claude models, preserve date suffixes, passthrough provider-prefixed models

This commit is contained in:
Jeon Suyeol
2026-03-06 12:00:54 +09:00
parent d99015f8cb
commit 32f3fa70e5
2 changed files with 33 additions and 28 deletions
@@ -1,6 +1,6 @@
import { normalizeModelID } from "../../shared/model-normalization"
const DATE_SUFFIX_PATTERN = /-\d{8}$/
const ANTHROPIC_PREFIX = "anthropic/"
export function mapClaudeModelToOpenCode(model: string | undefined): string | undefined {
if (!model) return undefined
@@ -8,6 +8,15 @@ export function mapClaudeModelToOpenCode(model: string | undefined): string | un
const trimmed = model.trim()
if (trimmed.length === 0) return undefined
const withoutDate = trimmed.replace(DATE_SUFFIX_PATTERN, "")
return normalizeModelID(withoutDate)
if (trimmed.includes("/")) {
return trimmed
}
const normalized = normalizeModelID(trimmed)
if (normalized.startsWith("claude-")) {
return `${ANTHROPIC_PREFIX}${normalized}`
}
return normalized
}