Skip to content

fix(session): strip think blocks from generated conversation titles - #505

Merged
Wang-Daoji merged 1 commit into
MemTensor:v1.1.9from
insuffer:fix/strip-think-from-generated-titles
Sep 28, 2026
Merged

Wang-Daoji merged 1 commit into
MemTensor:v1.1.9from
insuffer:fix/strip-think-from-generated-titles

Conversation

@insuffer

Copy link
Copy Markdown
Contributor

What

Fixes #432: auto-generated session titles could leak the title model's own chain of thought. cleanGeneratedTitle only 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…).

cleanGeneratedTitle now runs the existing stripThink helper first, so only user-visible text survives. Both title paths go through it (WebuiTitleService.generateTitle and maybeGenerateWebuiTitle).

Why

TITLE_GENERATION_REASONING_EFFORT is "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:

  • 8 new unit tests for 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 input
  • 2 new service-level tests in webui-title.test.ts: a provider answering <think>…</think>需求范围整理 stores 需求范围整理; a provider answering with thinking only stores no title
  • Each new test was confirmed to fail on the unpatched tree (verified by reverting only the source change and re-running)
  • tsc -p tsconfig.json --noEmit passes
  • Full workspace suite on Windows: 5590 tests, 44 failures — the same pre-existing flaky/platform failures as an unpatched checkout of main (43 failures there, with membership shifting run to run among the same timing-sensitive files: exec-session-tools, channel-gui-sync, session-dag/builder-queue, plus platform-only document-parsing/build-assets/office-skills). No title-related test fails, and both new test files pass in the full run

Notes

  • Reuses stripThink (src/utils/helpers.ts), the repo's established stripping mechanism, which already preserves backticked/prose mentions of <think> and Claude-family ant* artifact tags
  • stripThink covers think/thought tags but not <reasoning> blocks; covering that inside stripThink itself would affect every call site, so it seemed better as its own change if maintainers want it
  • Two suggestions from [Bug] 自动生成的会话标题会泄漏模型思考内容(包含 <think> 标签) #432 are intentionally left out to keep this PR focused, happy to follow up: falling back to the first user message when the model returns only thinking, and adding an explicit "do not include your reasoning" line to the title prompt

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.
@insuffer

Copy link
Copy Markdown
Contributor Author

Hi — first contribution to this repo. This fixes #432: when a reasoning model answers the title prompt with its own <think> block, the raw chain-of-thought was stored as the session title. The fix runs the repo's existing stripThink helper inside cleanGeneratedTitle and adds 10 tests (8 unit + 2 service-level), each verified to fail on the unpatched tree. The Linux CLI installer workflow run is waiting for fork approval — could a maintainer approve it so CI can validate the change? Happy to address any feedback.

@Wang-Daoji
Wang-Daoji changed the base branch from main to v1.1.9 September 28, 2026 08:53
@Wang-Daoji
Wang-Daoji merged commit 34ccdc0 into MemTensor:v1.1.9 Sep 28, 2026
2 checks passed
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] 自动生成的会话标题会泄漏模型思考内容(包含 <think> 标签)

2 participants