fix(opencode): truncate first user message as session title when no title model configured#20499
Open
FindTea wants to merge 2 commits intoanomalyco:devfrom
Open
fix(opencode): truncate first user message as session title when no title model configured#20499FindTea wants to merge 2 commits intoanomalyco:devfrom
FindTea wants to merge 2 commits intoanomalyco:devfrom
Conversation
…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
acee7e4 to
df37a4d
Compare
Author
|
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! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #20501
Type of change
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