fix: publish session.error event for invalid model selection (#8451)

This commit is contained in:
Surma
2026-02-09 22:27:48 +00:00
committed by GitHub
parent 3d6fb29f0c
commit 832902c8e3

View File

@@ -321,7 +321,18 @@ export namespace SessionPrompt {
history: msgs,
})
const model = await Provider.getModel(lastUser.model.providerID, lastUser.model.modelID)
const model = await Provider.getModel(lastUser.model.providerID, lastUser.model.modelID).catch((e) => {
if (Provider.ModelNotFoundError.isInstance(e)) {
const hint = e.data.suggestions?.length ? ` Did you mean: ${e.data.suggestions.join(", ")}?` : ""
Bus.publish(Session.Event.Error, {
sessionID,
error: new NamedError.Unknown({
message: `Model not found: ${e.data.providerID}/${e.data.modelID}.${hint}`,
}).toObject(),
})
}
throw e
})
const task = tasks.pop()
// pending subtask