fix(command): validate model before executing slash command (#5740)

This commit is contained in:
Jeon Suyeol 2025-12-19 01:35:40 +09:00 committed by GitHub
parent d5dcc55a47
commit 4bf882ba81
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1333,6 +1333,20 @@ export namespace SessionPrompt {
if (input.model) return Provider.parseModel(input.model)
return await lastModel(input.sessionID)
})()
try {
await Provider.getModel(model.providerID, model.modelID)
} catch (e) {
if (Provider.ModelNotFoundError.isInstance(e)) {
const { providerID, modelID, suggestions } = e.data
const hint = suggestions?.length ? ` Did you mean: ${suggestions.join(", ")}?` : ""
Bus.publish(Session.Event.Error, {
sessionID: input.sessionID,
error: new NamedError.Unknown({ message: `Model not found: ${providerID}/${modelID}.${hint}` }).toObject(),
})
}
throw e
}
const agent = await Agent.get(agentName)
const parts =