Skip to content

Commit e7428e4

Browse files
Clawdbotclaude
andcommitted
fix(session): prevent silent failure when small_model is invalid
When small_model is configured to an invalid model ID, ensureTitle() throws ProviderModelNotFoundError. This was an unhandled rejection because the call site didn't await or catch errors. Two changes: 1. Wrap ensureTitle() call with void + .catch() so errors are logged instead of becoming unhandled rejections. 2. In getSmallModel(), catch ModelNotFoundError when small_model config is invalid, log a warning, and fall back to heuristic model selection rather than throwing. Fixes anomalyco#14807 Co-Authored-By: Claude <[email protected]>
1 parent ae19003 commit e7428e4

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎packages/opencode/src/provider/provider.ts‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,18 @@ export namespace Provider {
12141214

12151215
if (cfg.small_model) {
12161216
const parsed = parseModel(cfg.small_model)
1217-
return getModel(parsed.providerID, parsed.modelID)
1217+
try {
1218+
return await getModel(parsed.providerID, parsed.modelID)
1219+
} catch (err) {
1220+
if (ModelNotFoundError.isInstance(err)) {
1221+
log.warn("configured small_model not found, falling back to heuristic selection", {
1222+
small_model: cfg.small_model,
1223+
})
1224+
// fall through to heuristic selection below
1225+
} else {
1226+
throw err
1227+
}
1228+
}
12181229
}
12191230

12201231
const provider = await state().then((state) => state.providers[providerID])

‎packages/opencode/src/session/prompt.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,11 +326,13 @@ export namespace SessionPrompt {
326326

327327
step++
328328
if (step === 1)
329-
ensureTitle({
329+
void ensureTitle({
330330
session,
331331
modelID: lastUser.model.modelID,
332332
providerID: lastUser.model.providerID,
333333
history: msgs,
334+
}).catch((err) => {
335+
log.error("failed to generate session title", { error: err })
334336
})
335337

336338
const model = await Provider.getModel(lastUser.model.providerID, lastUser.model.modelID).catch((e) => {

0 commit comments

Comments
 (0)