Skip to content

fix(session): prevent silent failure when small_model is invalid#14854

Closed
zerone0x wants to merge 1 commit intoanomalyco:devfrom
zerone0x:fix/14807-small-model-silent-failure
Closed

fix(session): prevent silent failure when small_model is invalid#14854
zerone0x wants to merge 1 commit intoanomalyco:devfrom
zerone0x:fix/14807-small-model-silent-failure

Conversation

@zerone0x
Copy link
Copy Markdown
Contributor

Issue for this PR

Closes #14807

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When small_model is set to an invalid model ID in config, session auto-title generation fails silently: the session keeps its default timestamp name and only an unhandled rejection appears in logs.

Root causes:

  1. ensureTitle() at the call site was not awaited and had no .catch() — any throw became an unhandled rejection.
  2. getSmallModel() forwarded ModelNotFoundError directly when the configured small_model was invalid, with no fallback.

Changes:

  • Wrap the ensureTitle() call with void + .catch() so errors are logged rather than silently lost.
  • In getSmallModel(), catch ModelNotFoundError when small_model is misconfigured, log a warning, then fall back to heuristic model selection (same logic as when small_model is not set).

How did you verify your code works?

Traced the call path in packages/opencode/src/session/prompt.ts and packages/opencode/src/provider/provider.ts. The existing getModel() function already uses ModelNotFoundError before it's declared in the same namespace, so the same pattern applies here.

Screenshots / recordings

N/A — no UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

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 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[bug] Session auto-naming silently fails when small_model is invalid

1 participant