Skip to content

fix(conversation): validate generated titles#261

Open
dom-mp wants to merge 2 commits into
NimbleBrainInc:mainfrom
dom-mp:title-generator
Open

fix(conversation): validate generated titles#261
dom-mp wants to merge 2 commits into
NimbleBrainInc:mainfrom
dom-mp:title-generator

Conversation

@dom-mp
Copy link
Copy Markdown
Contributor

@dom-mp dom-mp commented May 21, 2026

Summary

Fixes #34.
The auto-title generator previously accepted the title model output directly, so if the model answered/refused instead of producing a title, that refusal text could be stored as metadata.title and shown in conversation lists.
This PR hardens title generation by:

  • Treating the transcript as untrusted data to summarize.
  • Wrapping title input in explicit transcript boundaries.
  • Escaping injected closing tags in transcript content.
  • Sanitizing generated titles before storing them.
  • Rejecting refusal, apology, identity-response, and long-prose outputs.
  • Falling back to the first user message when the generated title is invalid.

Testing

  • bun test test/unit/auto-title.test.ts
  • bun run check
  • bun run format:check
  • bun run lint

dom-mp added 2 commits May 21, 2026 10:15
Treat the auto-title transcript as untrusted data, escape transcript boundaries, and reject refusal/prose outputs before storing conversation title metadata.
Fixes NimbleBrainInc#34
Expand generated-title validation to catch apology and identity-response variants, including curly-apostrophe forms like I’m sorry.
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.

Conversation title generator emits refusal text as the title

1 participant