You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(ai): a web_fetch budget cut inside a code block closes the fence before the truncation note and boundary tag #1298
priority/p2-mediumPriority P2: standard workscope/aiAI review pipeline, personas, prompts, LLM client, or RAGtype/bugType bug: the code does not do what it must
Copilot thread 0 on #1283, verified at 61f9b67. _apply_blank_line_cut cuts the rendered Markdown at a blank line or newline without regard to fences [code: src/devops_cli/ai/common_tools.py:395-407]. A budget cut inside a <pre> block therefore leaves its fence open, and the truncation note and </untrusted_web_page> land inside the code block. Page text still cannot forge the boundary, and the tag stays the last line of the tool result, so this is hardening rather than a v0.2.28 defect. It came in with #896 (878fe3f).
Acceptance criteria
A cut inside a fenced block closes the fence, using markdown-it-py (already a dependency), before the truncation note and the boundary tag. A test parses the result and finds the tag outside every fence.
changelog.d/<n>.md records the change; CHANGELOG.md and docs/ROADMAP.md are not edited.
A web_fetch page cut by its budget inside a code block left the block open, so the truncation note and the closing </untrusted_web_page> tag landed inside the code. _apply_blank_line_cut now closes the block first.
After choosing the cut point as before, it parses the text with markdown-it (already a dependency). If the cut falls inside a code block, it keeps the block's own closing line, including any blockquote or list prefix. If the cut falls on the opening line, it drops the block. The closing line can go over the budget by its own length.
Line endings are converted first: "\r\n" and a lone "\r" become "\n", CommonMark's own rule. markdownify keeps a lone "\r" in <pre> content and in link titles, and without the conversion the parser's line numbers would point at the wrong lines. That raised IndexError, or added a stray fence that opened a new block.
No change to the converter, the sanitizer, the wrapper, web_fetch_tool or DEFAULT_TRUNCATION_SUFFIX.
Adds changelog.d/1298.md and docs/agent/tasks/task-1298-web-fetch-cut-closes-open-fence.md. CHANGELOG.md and docs/ROADMAP.md are not edited.
Acceptance Criteria of docs/agent/tasks/task-1298-web-fetch-cut-closes-open-fence.md:
A cut inside a fenced block closes the fence, using markdown-it-py, before the truncation note and the boundary tag. test_render_untrusted_page_budget_cut_inside_code_block_closes_the_fence in tests/test_common_tools.py parses the result and finds neither the tag nor the note inside any fence: a block after a paragraph, a block that starts the page (cut mid-listing, on the opening line, and part way through the opening line), a block in a blockquote, a block in a list item, and a block after \r line endings.
changelog.d/1298.md records the change; CHANGELOG.md and docs/ROADMAP.md are not edited.
priority/p2-mediumPriority P2: standard workscope/aiAI review pipeline, personas, prompts, LLM client, or RAGtype/bugType bug: the code does not do what it must
Activity
dan-petty-bot commentedon Oct 8, 2026
Intake placed this item to v0.2.30: a critical fix can join v0.2.30 after it starts.
Malformed output could confuse the model reading the tool result, but the security boundary and tag position are preserved.A targeted fix in one function using markdown-it-py, which is already a dependency, plus one test.fix(ai): a web_fetch budget cut inside a code block closes the fence …
dan-petty-bot commentedon Oct 9, 2026
What changed
#1462, merged into
release/v0.2.30as eadfaa0.4 file(s) changed.
How it was verified
Check runs at bf350d5:
Acceptance Criteria of
docs/agent/tasks/task-1298-web-fetch-cut-closes-open-fence.md:test_render_untrusted_page_budget_cut_inside_code_block_closes_the_fenceintests/test_common_tools.pyparses the result and finds neither the tag nor the note inside any fence: a block after a paragraph, a block that starts the page (cut mid-listing, on the opening line, and part way through the opening line), a block in a blockquote, a block in a list item, and a block after\rline endings.changelog.d/1298.mdrecords the change;CHANGELOG.mdanddocs/ROADMAP.mdare not edited.uv run devops cipasses.feat(release): v0.2.30 (#1473)