Skip to content

fix(server): tell agents how to nest fenced code inside code blocks - #1

Open
pc-style wants to merge 19 commits into
mainfrom
t3code/fix-markdown-code-blocks
Open

pc-style wants to merge 19 commits into
mainfrom
t3code/fix-markdown-code-blocks

Conversation

@pc-style

@pc-style pc-style commented Sep 9, 2026

Copy link
Copy Markdown
Owner

When an agent replies with a code block that itself contains a fenced block (a prompt to paste, a README snippet), the chat renders it broken: the inner closing fence ends the outer block and the rest of the content spills out as plain prose. The renderer is right, that is standard CommonMark. The agent just never knew it had to use a longer fence.

This adds one sentence to the shared runtime instructions every provider adapter appends (Codex, Claude, Cursor, Grok, OpenCode, Antigravity): a code block containing triple backticks must be fenced with four backticks or ~~~. No parser change, since diverging from CommonMark would break copy/paste round-trips with GitHub and every other markdown surface.

Validation:

  • vp test run apps/server/src/provider/RuntimeInstructions.test.ts passes (6 tests, including a new one for the guidance).

Done with Claude Fable 5.1 in Claude Code.

🤖 Generated with Claude Code

@pc-style

pc-style commented Sep 9, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

A code block whose body contains triple backticks was rendered broken in
chat: the inner closing fence ended the outer block, and the rest spilled
out as prose. That is correct CommonMark, so the fix is to tell every
provider up front to use a longer fence in that case.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@pc-style
pc-style force-pushed the t3code/fix-markdown-code-blocks branch from f4a9b2b to c79ab38 Compare September 9, 2026 23:45
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:XXL labels Sep 14, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant