fix: ensure newlines around think tags for proper markdown rendering#20594
Merged
crazywoola merged 1 commit intolanggenius:mainfrom Jun 3, 2025
Merged
Conversation
- Fix markdown rendering issues when think content directly connects with markdown content
crazywoola
approved these changes
Jun 3, 2025
jsincorporated
pushed a commit
to jsincorporated/asaAi
that referenced
this pull request
Jul 8, 2025
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.
Fix markdown rendering issues when think content directly connects with markdown content
Fixes #20408
Summary
This PR addresses an issue where markdown content following think tags may not render correctly due to inconsistent newline handling. The problem specifically occurs when LLM responses have different formatting patterns for "thinking" content and regular responses.
Background
Different LLM providers handle the formatting between "thinking" content and regular responses differently:
This inconsistency leads to markdown rendering issues, particularly affecting:
Solution
The fix improves the
preprocessThinkTagfunction to:</details>tags and subsequent contentLong-term Consideration
While this frontend fix addresses the immediate rendering issues, a more comprehensive solution would involve:
Test Cases
The changes have been tested with the following prompts:
Test Prompt 1:
Test Prompt 2:
iShot_2025-06-03_18.46.46.mp4
Screenshots
Checklist
dev/reformat(backend) andcd web && npx lint-staged(frontend) to appease the lint gods