Formatting breaks when LLM response contains code blocks and special characters

Issue Description
I’ve encountered a formatting issue with responses. On rare occasions, often when the LLM is using special characters in code blocks (such as triple backticks and comment syntax), the response structure breaks down. Specifically, text appears in wrong sections, code bleeds into explanations, and the overall formatting becomes unusable. Further calls in the same chat continue with the same unreadable pattern

Steps to Reproduce

  1. Use “Ask” to work ona concept that requires use of special characters
  2. Request examples that include inline code with backticks
  3. Happens on rare occasion

Observed Behavior

  • Response starts normally but then loses proper formatting
  • Code appears directly mixed with explanations instead of in separate blocks
  • Text jumps to unexpected locations in the response
  • The structure collapses, making the guidance difficult to follow
  • Further interactions in chat have the same broken behavior

Expected Behavior
All responses should maintain proper separation between explanation text and code blocks, regardless of the special characters used within the content.

Environment

  • Cursor AI version: 0.46.8
  • Operating system: Mac Sonoma

I appreciate your help in investigating this issue!