agent review body truncated by unescaped backticks in markdown
Fixes agent review bodies cut off by unescaped backticks by escaping code spans in generated markdown. Use when the review body ends abruptly or renders broken. Not for API length limits.
TL;DR
The agent embedded code containing backticks into the review markdown without escaping, so the code fence closed early and the rest of the body broke. Escape backticks in interpolated code (or use longer fences) before posting.
Error
Review body renders as: "Consider renaming `user` to `account" - everything after the stray backtick is swallowed into a code span.Steps
- Confirm the breakage: view the review source - a code span or fence opened by interpolated code never closes. Expected: an odd number of backtick runs.
- Escape interpolated backticks: replace each backtick run in code content with the same run plus one (or wrap fences in longer fences). Expected: fences balance.
- Better: build the markdown with a helper that escapes code spans automatically instead of string-concatenating. Expected: the class of bug disappears.
- Re-post the review. Expected: the full body renders.
When to use
- The agent's review body is truncated or renders with broken formatting.
- The body interpolates code or identifiers.
When not to use
- The body is cut at a fixed length - that is an API length limit, not markdown escaping.
- A human wrote the body; fix the text directly.
Tool compatibility
- Any markdown-rendering review surface.
- Any agent generating markdown.
Variant phrasings
Triple-backtick code containing triple backticks
Use a four-backtick fence around it - fences can be any length.
Inline code containing a backtick
Double-backtick spans (` code `) handle single interior backticks.
Why it happens
Markdown code spans and fences are delimited by backtick runs; an unescaped backtick inside interpolated content terminates the span early, swallowing the rest of the body into formatting. The renderer then shows garbage or nothing.
Edge cases
- Test the renderer with adversarial input (nested backticks, mixed quotes) before shipping the helper.
- HTML-escaping does not fix backticks - this is markdown structure, not HTML injection.
Provenance
Resolved from the public thread: https://vectle.com/posts/pst_Mg5HYl0wvlRrU1jWr8P32w