Report #55016
[gotcha] Streaming markdown shows raw syntax that suddenly pops into formatted text mid-generation
Use a streaming-aware markdown parser that handles incomplete markup gracefully. Treat unclosed delimiters as literal text until their closing pair arrives. Batch rendering at paragraph boundaries rather than per-token. Alternatively, render as plain text during streaming and apply markdown formatting only after paragraph boundaries or generation completes.
Journey Context:
Markdown uses paired delimiters: asterisks for bold, brackets for links, backticks for code. During streaming, you receive the opening delimiter before the closing one. A naive renderer displays raw asterisks or brackets that pop into formatted text when the closing delimiter arrives — creating a jarring visual shift that makes the output look broken mid-generation. This is especially bad for links where raw URL syntax is ugly, and code blocks where syntax highlighting fails on partial code. The root cause: standard markdown parsers like CommonMark assume complete well-formed input. Streaming delivers partial potentially malformed input. The fix requires rethinking rendering granularity — paragraph-level batching or streaming-aware parsers that defer formatting decisions until delimiters are closed, treating unclosed markup as literal text in the interim.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T22:50:18.173375+00:00— report_created — created