Skip to content

Conversation

@poornapragnyah
Copy link
Contributor

@poornapragnyah poornapragnyah commented Oct 28, 2025

Summary

Fixes #10284

This PR fixes a bug where LLM reasoning tags (e.g., <think>...) are incorrectly saved as chat titles, particularly when using models like qwen3:8b on Ollama. This pollutes the database and causes a UI bug where the "Delete Conversation" modal overflows, hiding the "Delete" button.

This fix is in two parts:

  1. Backend (Root Cause): A new sanitizeTitle utility is added to packages/api to strip all <think>...</think> blocks from new titles before they are saved. This is integrated into the api/server/controllers/agents/client.js controller.
  2. Frontend (Defensive Fix): The delete modal (client/src/components/Conversations/ConvoOptions/DeleteButton.tsx) is updated with truncate w-full. This defensively handles any existing malformed titles already in the database, preventing the UI overflow.

Change Type

  • Bug fix (non-breaking change which fixes an issue)

Testing

I performed both automated and manual testing for this two-part fix.

Backend Testing (Automated):

  1. Created a new utility packages/api/src/utils/sanitizeTitle.ts.
  2. Created a new test file packages/api/src/utils/sanitizeTitle.spec.ts with 34 new unit tests covering all edge cases (stripping, case-insensitivity, attributes, fallbacks, etc.).
  3. Updated api/server/controllers/agents/client.js with 2 new integration tests to verify the sanitizeTitle function is correctly called.
  4. Result: All backend unit and integration tests passed.

Frontend Testing (Automated & Manual):

  1. Automated: All automated frontend test cases passed, confirming the changes did not introduce any regressions.
  2. Manual (Fix for new chats):
    • Started a new chat with the qwen3:8b model.
    • Verified: The title generated in the sidebar was clean (e.g., "User Hi Greeting") and did not contain <think> tags.
  3. Manual (Fix for old chats):
    • Located an existing chat with a malformed title (<think>...).
    • Clicked the "Delete" button.
    • Verified: The modal appeared correctly. The title was truncated (e.g., This will delete <think>...), and the "Delete" button was visible and clickable.

Test Configuration:

  • OS: Fedora 41
  • Browser: Brave 1.83.112
  • Endpoint: Ollama (Custom Endpoint)
  • Model: qwen3:8b (to reproduce the bug)

Checklist

  • My code adheres to this project's style guidelines
  • I have performed a self-review of my own code
  • I have commented in any complex areas of my code (JSDoc for sanitizeTitle)
  • I have made pertinent documentation changes (N/A for this fix)
  • My changes do not introduce new warnings
  • I have written tests demonstrating that my changes are effective or that my feature works
  • Local unit tests pass with my changes
  • Any changes dependent on mine have been merged and published in downstream modules.
  • A pull request for updating the documentation has been submitted.

@danny-avila danny-avila changed the title fix: Sanitize LLM titles by stripping <think> tags and fix modal over… ✂️ fix: Trim Reasoning Tags from Titles and Delete Button Visibility Oct 29, 2025
@danny-avila danny-avila changed the base branch from main to dev October 29, 2025 16:34
@danny-avila danny-avila merged commit 05c7061 into danny-avila:dev Oct 29, 2025
7 checks passed
@poornapragnyah poornapragnyah deleted the fix/ui/delete-modal-overflow branch October 29, 2025 17:39
@poornapragnyah poornapragnyah restored the fix/ui/delete-modal-overflow branch October 29, 2025 17:49
@poornapragnyah poornapragnyah deleted the fix/ui/delete-modal-overflow branch October 29, 2025 17:56
JustinBeaudry pushed a commit to Actual-Reality/LibreChat that referenced this pull request Nov 12, 2025
…anny-avila#10285)

* fix: Sanitize LLM titles by stripping <think> tags and fix modal overflow

* chore: linting

* chore: Simplify title sanitization by removing unnecessary variable assignment and import order

---------

Co-authored-by: Danny Avila <[email protected]>
Guiraud pushed a commit to Guiraud/LibreChat that referenced this pull request Nov 21, 2025
…anny-avila#10285)

* fix: Sanitize LLM titles by stripping <think> tags and fix modal overflow

* chore: linting

* chore: Simplify title sanitization by removing unnecessary variable assignment and import order

---------

Co-authored-by: Danny Avila <[email protected]>
patricksn3ll pushed a commit to patricksn3ll/LibreChat that referenced this pull request Dec 11, 2025
…anny-avila#10285)

* fix: Sanitize LLM titles by stripping <think> tags and fix modal overflow

* chore: linting

* chore: Simplify title sanitization by removing unnecessary variable assignment and import order

---------

Co-authored-by: Danny Avila <[email protected]>
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]: Long Chat Title Causes Delete Confirmation Modal Content to Overflow, Hiding Confirmation Button

2 participants