Skip to content

fix(session): retry title generation and fall back to the session model - #49223

Open
thom801 wants to merge 1 commit into
anomalyco:devfrom
thom801:fix/session-title-fallback
Open

thom801 wants to merge 1 commit into
anomalyco:devfrom
thom801:fix/session-title-fallback

Conversation

@thom801

@thom801 thom801 commented Sep 15, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #42287, #30662

Type of change

  • Bug fix

What does this PR do?

Session title generation runs once with the small model and silently fails: any error leaves the session with its default New session - ... title forever. ensureTitle only fires while the session has exactly one real user message, and the small-model LLM call dies without a fallback (the caller ignores it).

This PR makes two changes in ensureTitle:

  • Fall back to the session model (small: false) when the small-model title request errors, with a warning log.
  • Drop the single-user-message guard so a session that still has a default title retries title generation on a later message, instead of never retrying.

Trigger examples: a small model blocked by provider guardrails/ZDR (reported in #42287), or a reasoning model returning only a <think> block (#30662).

How did you verify your code works?

Added TestLLMServer.titleError to simulate title request failures, plus two tests in packages/opencode/test/session/prompt.test.ts:

  • title generation falls back to a second attempt when the title request errors
  • title generation retries on a later message while the title is still default

bun test test/session/ passes (415 pass, 0 fail); bun run typecheck and oxlint pass.

Checklist

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

Title generation runs once with the small model and silently fails: any
error leaves the session with its default title forever, because
ensureTitle only fires when the session has exactly one real user
message and never falls back to the main model.

- Retry title generation on later messages while the title is still
  default (drop the single-message guard), so transient failures recover.
- Fall back to the session model (small=false) when the small-model
  request errors, instead of swallowing the failure.
- Add TestLLMServer.titleError to simulate title request failures and
  cover both behaviors in the prompt test suite.

Fixes anomalyco#42287, anomalyco#30662
@kvnloo

kvnloo commented Sep 15, 2026

Copy link
Copy Markdown

Why this matters

Session title generation is one-shot on the small model; errors leave New session - … forever with no later retry (#42287 #30662).

Evidence

Tip cb48ac8 (base dev e03db9b):

  • packages/opencode/src/session/prompt.tsgenerateTitle; on small-model error, retry with session model (small: false) + warn
  • drops the single-user-message-only gate so default titles can regenerate on later turns
  • live: bun test test/session/prompt.test.ts -t "title"2/2 pass (fallback + later-message retry); same filter on dev has 0 title tests yet
  • CI: standards / compliance / duplicates success

Confirms scope. Happy to help land as-is.

Ask (design, light) — prospective

  1. Is stuck default title a one-off, or a class of silent one-shot side LLM jobs that need fallback + retry policy?
  2. For never-again: shared “best-effort LLM side effect” helper (small → session model → give up), or per-call sites + checklist?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Session title silently empty when the title model is a reasoning model (returns only a <think> block)

2 participants