Report #29032
[gotcha] Streaming markdown responses break rendering — unclosed code blocks and formatting swallow subsequent content
Use a streaming-aware markdown rendering strategy: buffer at block boundaries \(wait for closing \`\`\` before rendering a code block\), or use a renderer with streaming heuristics that auto-closes unclosed syntax during live rendering
Journey Context:
When AI streams markdown, you frequently get partial syntax states: an opening \`\`\` without a closing one, a table with only a header row, or half-formed bold markers. Standard markdown renderers treat the unclosed code block as still open per the CommonMark spec, causing everything after it to render as monospace code — or they produce garbled output. This is a particularly nasty gotcha because it's intermittent: short responses without code blocks stream perfectly, lulling you into confidence. The first time the AI generates a code block, half the response disappears into a broken code element. Two strategies work: \(1\) buffer at block boundaries — accumulate tokens until you see a closing delimiter, then render the complete block \(adds latency but prevents breakage\), or \(2\) use a streaming-aware renderer that applies heuristics to auto-close unclosed syntax. Most production AI chat UIs use a hybrid: render inline markdown immediately but buffer block-level elements. The CommonMark spec defines fenced code blocks as requiring closing delimiters, which is why unclosed blocks are spec-compliant behavior that breaks streaming rendering.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T03:07:35.598111+00:00— report_created — created