Repository navigation
fix(session): strip think blocks from generated conversation titles - #505
Merged
Wang-Daoji merged 1 commit intoSep 28, 2026
Merged
Conversation
cleanGeneratedTitle only trimmed quotes, prefixes and punctuation, so a reasoning model answering the title prompt with its own chain of thought stored the raw <think>…</think> text as the session title (MemTensor#432). reasoningEffort is none, but inherently-reasoning models ignore it, so strip defensively with the existing stripThink helper. When the model produces only thinking, the title stays empty and the session keeps its default title instead of exposing reasoning. Adds unit tests for cleanGeneratedTitle and two WebuiTitleService tests; each fails on the unpatched tree.
Contributor
Author
|
Hi — first contribution to this repo. This fixes #432: when a reasoning model answers the title prompt with its own |
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.
What
Fixes #432: auto-generated session titles could leak the title model's own chain of thought.
cleanGeneratedTitleonly trimmed quotes/prefixes/punctuation, so when a reasoning model answers the title prompt with a<think>…</think>block, the raw reasoning text was stored as the session title (the sidebar showed titles like<think>The user is asking about…).cleanGeneratedTitlenow runs the existingstripThinkhelper first, so only user-visible text survives. Both title paths go through it (WebuiTitleService.generateTitleandmaybeGenerateWebuiTitle).Why
TITLE_GENERATION_REASONING_EFFORTis"none", but inherently-reasoning models (DeepSeek-R1, GPT-OSS with reasoning, …) ignore that and still emit thinking blocks, so the leak happens in practice — see the screenshots in #432. When the model produces only thinking, the title is now left empty instead of storing the reasoning text, so the session keeps its default title rather than exposing chain-of-thought.How it was verified
Windows 11, workspace
App/memmy-agent:cleanGeneratedTitle: think/thought blocks (closed, multiline, unclosed), thinking-only → empty title, whitespace/punctuation still collapsed after stripping, backticked<think>mentions in prose preserved, empty/null inputwebui-title.test.ts: a provider answering<think>…</think>需求范围整理stores需求范围整理; a provider answering with thinking only stores no titletsc -p tsconfig.json --noEmitpassesexec-session-tools,channel-gui-sync,session-dag/builder-queue, plus platform-onlydocument-parsing/build-assets/office-skills). No title-related test fails, and both new test files pass in the full runNotes
stripThink(src/utils/helpers.ts), the repo's established stripping mechanism, which already preserves backticked/prose mentions of<think>and Claude-familyant*artifact tagsstripThinkcoversthink/thoughttags but not<reasoning>blocks; covering that insidestripThinkitself would affect every call site, so it seemed better as its own change if maintainers want it