Report #50638
[gotcha] Streaming markdown responses break rendering when syntax delimiters span chunk boundaries
Use a streaming-aware markdown renderer that gracefully handles incomplete syntax. Buffer tokens until complete markdown blocks are closed before rendering, or use a renderer that treats unclosed delimiters as plain text until their closing pair arrives. The Vercel AI SDK provides streaming markdown utilities that handle this; alternatively, implement a fence-detection buffer that holds back content between opening and closing delimiters before flushing to the renderer.
Journey Context:
When tokens are piped directly into a standard markdown renderer, incomplete syntax causes cascading visual failures. An unclosed \*\* makes everything after it render as bold. An unclosed \`\`\` code fence swallows the rest of the response into monospace. A single stray backtick can break the entire page layout. This is intermittent and content-dependent — it only manifests when the AI's output happens to have syntax spanning chunk boundaries, making it hard to reproduce and debug. Teams often don't discover it until production traffic hits it. The tradeoff is between perceived latency \(showing tokens instantly\) and visual stability \(buffering for complete syntax\). Visual stability wins: a flickering broken layout is worse UX than a brief delay before clean content appears. The key insight is that markdown is a stateful format — you cannot render partial markdown the same way you render partial plain text.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T15:28:45.614032+00:00— report_created — created