Skip to content

fix(opencode): truncate first user message as session title when no title model configured#20499

Open
FindTea wants to merge 2 commits intoanomalyco:devfrom
FindTea:fix/session-auto-title
Open

fix(opencode): truncate first user message as session title when no title model configured#20499
FindTea wants to merge 2 commits intoanomalyco:devfrom
FindTea:fix/session-auto-title

Conversation

@FindTea
Copy link
Copy Markdown

@FindTea FindTea commented Apr 1, 2026

Issue for this PR

Closes #20501

Type of change

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

What does this PR do?

Without a dedicated title model configured, sessions were named with raw ISO timestamps (e.g. "New Session 2026-01-01T12:00:00.000Z"), making the session list completely unusable. When small_model was configured, the LLM would generate a title but the result was often too abstract and didn't reflect what the session was actually about.

This PR derives the session title directly from the first line of the user's first message when no explicit agent.title.model is configured. This is instant, costs no tokens, and always produces an accurate and recognizable title.

LLM-based title generation is preserved for users who explicitly configure a model under agent.title.model.

How did you verify your code works?

Manually tested: sent a first message in a new session, confirmed the session title immediately updated to the truncated first line of the message without any LLM call.

Screenshots / recordings

N/A

Checklist

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

FindTea added 2 commits April 7, 2026 08:48
…itle model configured

When no dedicated title agent model is explicitly configured, the previous
code would fall through to using small_model (if set) or the main model to
generate a session title via LLM. This burns tokens on every new session.

Instead, truncate the first non-synthetic text line of the user's first
message directly as the title. This is instant and costs nothing.

LLM-based title generation is preserved for users who explicitly configure
a model under agent.title.model.
Verify that:
- First user message line is used as session title when no title model configured
- Long messages are truncated to 100 chars with ellipsis
- Only the first line of multiline messages is used
- Manually set titles are not overwritten
@FindTea
Copy link
Copy Markdown
Author

FindTea commented Apr 7, 2026

The failing \e2e (windows)\ check is unrelated to this PR's changes.

The failure is in \projects/workspaces.spec.ts\ (\can delete a workspace) — a UI timing/flaky test on Windows. This same test caused \e2e (windows)\ to fail on the \dev\ branch itself on the same day (run 24057065303), so it's a pre-existing environment issue, not a regression introduced here.

This PR only modifies \packages/opencode/src/session/prompt.ts\ and \packages/opencode/test/session/prompt-effect.test.ts. All unit tests (linux + windows) pass. Could a maintainer re-run the Windows e2e job or override the check? Thanks!

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.

[bug] Session list fills with unreadable timestamps when no title model is configured

1 participant