fix: add explicit fallback model and prevent direct opencode provider calls (#4653)

Co-authored-by: Aiden Cline <aidenpcline@gmail.com>
This commit is contained in:
Huang Qi 2025-11-24 12:51:15 +08:00 committed by GitHub
parent eb009d5959
commit b4fd4bb257
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 14 additions and 3 deletions

View file

@ -685,7 +685,14 @@ export namespace Provider {
}
}
}
return getModel("opencode", "gpt-5-nano")
// Check if opencode provider is available before using it
const opencodeProvider = await state().then((state) => state.providers["opencode"])
if (opencodeProvider && opencodeProvider.info.models["gpt-5-nano"]) {
return getModel("opencode", "gpt-5-nano")
}
return undefined
}
const priority = ["gpt-5", "claude-sonnet-4", "big-pickle", "gemini-3-pro"]

View file

@ -1408,7 +1408,8 @@ export namespace SessionPrompt {
input.history.filter((m) => m.info.role === "user" && !m.parts.every((p) => "synthetic" in p && p.synthetic))
.length === 1
if (!isFirst) return
const small = await Provider.getSmallModel(input.providerID)
const small =
(await Provider.getSmallModel(input.providerID)) ?? (await Provider.getModel(input.providerID, input.modelID))
const options = pipe(
{},
mergeDeep(ProviderTransform.options(small.providerID, small.modelID, small.npm ?? "", input.session.id)),

View file

@ -73,7 +73,10 @@ export namespace SessionSummary {
await Session.updateMessage(userMsg)
const assistantMsg = messages.find((m) => m.info.role === "assistant")!.info as MessageV2.Assistant
const small = await Provider.getSmallModel(assistantMsg.providerID)
const small =
(await Provider.getSmallModel(assistantMsg.providerID)) ??
(await Provider.getModel(assistantMsg.providerID, assistantMsg.modelID))
const options = pipe(
{},
mergeDeep(ProviderTransform.options(small.providerID, small.modelID, small.npm ?? "", assistantMsg.sessionID)),