anomalyco / anomalyco/opencode
Session title silently empty when the title model is a reasoning model (returns only a `<think>` block)
@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.ts — ensureTitle():
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
- Set the small/title model to a reasoning model (e.g.
openrouter/z-ai/glm-4.6). - Start a new session and send a normal message.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.