anomalyco / anomalyco/opencode

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

Open
#42,287 0 comments 0 reactions 1 assignee View on GitHub

@kitlangton is already working on this.

Since Aug 13, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

ensureTitle() generates the session title with the small model (small: true).
When that model is a reasoning model (e.g. GLM-4.6 / Kimi K3 via OpenRouter), the
completion is frequently reasoning-only: after the <think>…</think> strip in
ensureTitle, the remaining text is empty. The function then hits if (!cleaned) return
and the session silently keeps its default New session - <timestamp> title.

It is intermittent (a reasoning model returns usable text on some turns, think-only on
others), which matches the "happens at times" reports below.

Affected code

packages/opencode/src/session/prompt.tsensureTitle():

const cleaned = text
  .replace(/<think>[\s\S]*?<\/think>\s*/g, "")
  .split("\n").map(l => l.trim()).find(l => l.length > 0)
if (!cleaned) return   // reasoning-only output -> empty -> no title, silently
Steps to reproduce
  1. Set the small/title model to a reasoning model (e.g. openrouter/z-ai/glm-4.6).
  2. Start a new session and send a normal message.
  3. On turns where the title model returns only reasoning, the title stays
    New session - <timestamp>.
Root cause

ensureTitle withholds the title whenever the model output is empty, instead of
falling back to a deterministic source. Reasoning-only output is the common trigger.

Related open issues

Same symptom: #13710, #31592, #34257, #30662.
Same underlying family (reasoning-only / empty output treated as a successful, empty
result): #37372, #41469, #41571.

Proposed fix

Fall back to the first user message when the model output is empty — the title is then
never withheld, regardless of why the model returned nothing. I have this change ready
and will open a PR referencing this issue.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.