fix(plugin): persist ultrawork variant on same-model override and normalize Claude model IDs

🤖 Generated with [OhMyOpenCode](https://github.com/code-yeongyu/oh-my-openagent)
This commit is contained in:
YeonGyu-Kim
2026-03-16 13:53:28 +09:00
parent 32a296bf1e
commit 47d1ad7bb9
3 changed files with 20 additions and 3 deletions
@@ -75,6 +75,10 @@ describe("mapClaudeModelToOpenCode", () => {
expect(mapClaudeModelToOpenCode("anthropic/claude-sonnet-4-6")).toEqual({ providerID: "anthropic", modelID: "claude-sonnet-4-6" })
})
it("#when called with anthropic/claude-3.5-sonnet #then normalizes dots before splitting into object format", () => {
expect(mapClaudeModelToOpenCode("anthropic/claude-3.5-sonnet")).toEqual({ providerID: "anthropic", modelID: "claude-3-5-sonnet" })
})
it("#when called with openai/gpt-5.2 #then splits into object format", () => {
expect(mapClaudeModelToOpenCode("openai/gpt-5.2")).toEqual({ providerID: "openai", modelID: "gpt-5.2" })
})
@@ -20,7 +20,16 @@ function mapClaudeModelString(model: string | undefined): string | undefined {
const aliasResult = CLAUDE_CODE_ALIAS_MAP.get(trimmed.toLowerCase())
if (aliasResult) return aliasResult
if (trimmed.includes("/")) return trimmed
if (trimmed.includes("/")) {
const [providerID, ...modelParts] = trimmed.split("/")
const modelID = modelParts.join("/")
if (providerID.length === 0 || modelID.length === 0) return trimmed
return modelID.startsWith("claude-")
? `${providerID}/${normalizeModelID(modelID)}`
: trimmed
}
const normalized = normalizeModelID(trimmed)
+6 -2
View File
@@ -110,12 +110,16 @@ function applyResolvedUltraworkOverride(args: {
if (!override.providerID || !override.modelID) return
const targetModel = { providerID: override.providerID, modelID: override.modelID }
const messageId = output.message["id"] as string | undefined
if (isSameModel(output.message.model, targetModel)) {
if (validatedVariant && messageId) {
scheduleDeferredModelOverride(messageId, targetModel, validatedVariant)
log(`[ultrawork-model-override] Persist validated variant for active model: ${override.modelID}`)
return
}
log(`[ultrawork-model-override] Skip override; target model already active: ${override.modelID}`)
return
}
const messageId = output.message["id"] as string | undefined
if (!messageId) {
log("[ultrawork-model-override] No message ID found, falling back to direct mutation")
output.message.model = targetModel