fix: avoid Untitled Session when title generation fails#3081
Open
CnsMaple wants to merge 2 commits into
Open
Conversation
- Remove conflicting <think> tags from the title prompt to reduce empty responses from models with /no_think system instruction - Fall back to the first 50 characters of the user's first message when LLM title generation fails entirely 💘 Generated with Crush
Add unit tests for the title generation fallback that runs when the LLM call fails. Covers: - short prompt used verbatim as fallback title - long prompt truncated to 50 runes with ellipsis suffix - rune-aware truncation (multi-byte chars must not be split) - empty prompt leaves the session title untouched Uses a stub fantasy.LanguageModel that always returns an error from Stream, so the small+large fallback path is exercised without any network or provider dependency. 💘 Generated with Crush
67f2214 to
c055549
Compare
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.
Summary
<think>//no_thinkpattern from the title prompt that could cause some models to return empty responsesTest plan
go build ./internal/agent/compiles cleanlygo test ./internal/agent/passesTestGenerateTitle_TruncatesLongPrompt_WithEllipsis(and the related tests) — seeinternal/agent/generate_title_test.go