fix(shared): switch promptWithModelSuggestionRetry to use promptAsync

This commit is contained in:
Peïo Thibault 2026-02-07 13:38:25 +01:00
parent 2c394cd497
commit b8221a883e

View File

@ -84,28 +84,7 @@ export async function promptWithModelSuggestionRetry(
client: Client,
args: PromptArgs,
): Promise<void> {
try {
await client.session.prompt(args as Parameters<typeof client.session.prompt>[0])
} catch (error) {
const suggestion = parseModelSuggestion(error)
if (!suggestion || !args.body.model) {
throw error
}
log("[model-suggestion-retry] Model not found, retrying with suggestion", {
original: `${suggestion.providerID}/${suggestion.modelID}`,
suggested: suggestion.suggestion,
})
await client.session.prompt({
...args,
body: {
...args.body,
model: {
providerID: suggestion.providerID,
modelID: suggestion.suggestion,
},
},
} as Parameters<typeof client.session.prompt>[0])
}
// NOTE: Model suggestion retry removed — promptAsync returns 204 immediately,
// model errors happen asynchronously server-side and cannot be caught here
await client.session.promptAsync(args as Parameters<typeof client.session.promptAsync>[0])
}