Skip to content

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

Closed

Description

@joaomj

Description

Bug: Session auto-naming silently fails when small_model is invalid

Summary

When small_model is configured to an invalid model ID (example: openai/gpt-nano), session auto-title generation fails, but the failure is silent in normal UX. The session keeps the default title (New session - ...) and only an unhandled rejection is logged.

Environment

  • Source analysis branch/commit: dev @ 8f2d8dd47a45a4b3972ac8badc09cc280f84b838

Why this happens (source-level)

  1. ensureTitle() is invoked without await and without a top-level .catch(...):
    • packages/opencode/src/session/prompt.ts:329
  2. ensureTitle() resolves model with Provider.getSmallModel(...) first:
    • packages/opencode/src/session/prompt.ts:1923
  3. If cfg.small_model is set, getSmallModel() does strict lookup and returns getModel(...) directly:
    • packages/opencode/src/provider/provider.ts:1215
  4. Invalid small_model throws ProviderModelNotFoundError, which bubbles to unhandled rejection path:
    • packages/opencode/src/index.ts:36

Suggested fix (error handling + resilience)

1) Prevent silent failure at call site

Wrap title task invocation in a safe fire-and-forget pattern:

void ensureTitle({...}).catch((err) => {
  log.error("failed to generate session title", { error: err })
  // optionally emit a non-blocking session warning event
})

2) Harden getSmallModel() against invalid small_model

If cfg.small_model is invalid:

  • log a warning with configured value,
  • fall back to provider heuristics (haiku/flash/gpt-5-nano) or current conversation model,
  • avoid throwing in non-critical title-generation path.

3) Optional startup/config validation

Validate small_model exists at startup or config load and surface a clear warning immediately.

User workaround

Use a valid small_model ID. For example:

{
  "small_model": "openai/gpt-5-nano"
}

After switching to a valid ID, auto-naming works again.

Related issues

Plugins

No response

OpenCode version

1.2.10

Steps to reproduce

Reproduction

  1. Set an invalid small model in config:
{
  "$schema": "https://opencode.ai/config.json",
  "small_model": "openai/gpt-nano"
}
  1. Start OpenCode and create a new session.
  2. Send the first user message.
  3. Wait for auto-title generation.

Expected behavior

  • Either:
    • Session title is auto-generated successfully, or
    • User receives a visible warning/error that title generation failed.
  • The failure should not be silent.

Actual behavior

  • Session title remains default (New session - ...).
  • No clear user-facing error for title generation failure.
  • Log shows only unhandled rejection:
ERROR ... service=default e=ProviderModelNotFoundError rejection

Screenshot and/or share link

No response

Operating System

macOS 26.3

Terminal

Ghostty

Activity

  1. github-actions commented on Feb 23, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If your issue adds something new (e.g., specifically invalid small_model config values vs. a disabled model), please clarify how it differs from #9902 so maintainers can determine if it should be merged or tracked separately.

  2. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 23, 2026
  3. added a commit that references this issue on Feb 24, 2026
    e7428e4
  4. added a commit that references this issue on Mar 13, 2026
    8d2017d
  5. github-actions commented on Apr 25, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions