Skip to content

fix: avoid Untitled Session when title generation fails#3081

Open
CnsMaple wants to merge 2 commits into
charmbracelet:mainfrom
CnsMaple:fix/untitled-session
Open

fix: avoid Untitled Session when title generation fails#3081
CnsMaple wants to merge 2 commits into
charmbracelet:mainfrom
CnsMaple:fix/untitled-session

Conversation

@CnsMaple

@CnsMaple CnsMaple commented Jun 5, 2026

Copy link
Copy Markdown

Summary

  • Removes conflicting <think> / /no_think pattern from the title prompt that could cause some models to return empty responses
  • When LLM title generation fails entirely (both small and large model), falls back to first 50 chars of the user's first message instead of the hardcoded "Untitled Session"
  • Adds unit tests covering the fallback paths: short prompt used verbatim, long prompt truncated with ellipsis, rune-aware truncation (multi-byte chars), and empty prompt no-op

Test plan

  • go build ./internal/agent/ compiles cleanly
  • go test ./internal/agent/ passes
  • Fallback behavior covered by TestGenerateTitle_TruncatesLongPrompt_WithEllipsis (and the related tests) — see internal/agent/generate_title_test.go

- 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
@CnsMaple CnsMaple force-pushed the fix/untitled-session branch 2 times, most recently from 67f2214 to c055549 Compare June 5, 2026 07:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant