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:
@@ -75,6 +75,10 @@ describe("mapClaudeModelToOpenCode", () => {
|
|||||||
expect(mapClaudeModelToOpenCode("anthropic/claude-sonnet-4-6")).toEqual({ providerID: "anthropic", modelID: "claude-sonnet-4-6" })
|
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", () => {
|
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" })
|
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())
|
const aliasResult = CLAUDE_CODE_ALIAS_MAP.get(trimmed.toLowerCase())
|
||||||
if (aliasResult) return aliasResult
|
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)
|
const normalized = normalizeModelID(trimmed)
|
||||||
|
|
||||||
|
|||||||
@@ -110,12 +110,16 @@ function applyResolvedUltraworkOverride(args: {
|
|||||||
if (!override.providerID || !override.modelID) return
|
if (!override.providerID || !override.modelID) return
|
||||||
|
|
||||||
const targetModel = { providerID: override.providerID, modelID: override.modelID }
|
const targetModel = { providerID: override.providerID, modelID: override.modelID }
|
||||||
|
const messageId = output.message["id"] as string | undefined
|
||||||
if (isSameModel(output.message.model, targetModel)) {
|
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}`)
|
log(`[ultrawork-model-override] Skip override; target model already active: ${override.modelID}`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const messageId = output.message["id"] as string | undefined
|
|
||||||
if (!messageId) {
|
if (!messageId) {
|
||||||
log("[ultrawork-model-override] No message ID found, falling back to direct mutation")
|
log("[ultrawork-model-override] No message ID found, falling back to direct mutation")
|
||||||
output.message.model = targetModel
|
output.message.model = targetModel
|
||||||
|
|||||||
Reference in New Issue
Block a user