Skip to content

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

Open
pc-style wants to merge 1 commit into
mainfrom
t3code/fix-markdown-code-blocks
Open

fix(server): tell agents how to nest fenced code inside code blocks#1
pc-style wants to merge 1 commit 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

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 commented Sep 9, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant