mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[PR #4761] [CLOSED] [Engine] tool parser: quoted Markdown code and thinking blocks stay text #5167
Labels
No labels
needs-format
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Niko1221/Strata#5167
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Niko1221/Strata/pull/4761
Author: @Tsury
Created: 10/30/2026
Status: ❌ Closed
Base:
main← Head:fix/parser-markdown-code📝 Commits (1)
a143449[Engine] tool parser: quoted Markdown code and thinking blocks stay text (#4702, #4703, #4704)📊 Changes
3 files changed (+78 additions, -31 deletions)
View changed files
📝
serve/frontend.py(+42 -22)📝
serve/test_parser_track.py(+14 -9)📝
serve/test_tool_corpus.py(+22 -0)📄 Description
Problem and result
A quoted example in an answer can run as a real tool call, because the parser's code tracking misses three Markdown shapes:
```closes a four-backtick fence, so a call shown inside it is outside "code".</think>rule (#4077) drops the closing tag of a thinking block the answer quotes, and that reset also ends the fence, so a call in the same example runs. In the plain case, the answer simply loses the tag.After this change, all four fixtures from these issues give no call and the whole text as the answer, with recover on and off, whole and in pieces.
Related discussion
Fixes #4702, #4703 and #4704. They are one PR because all three change the same tracked state (
fence,line,ticks) and its snapshots, so separate PRs would conflict on every line.Approach
fencenow holds the opening run, not one character. A fence closes on a line of its own, of the same character and at least as long, as CommonMark says.indentedis true after a blank line, and stays true while lines keep a code indent. A call on such a line is a quote. A call indented right after a line of text is still a call, as #4703 suggests.quoted_thinkcounts<think>lines of the answer. A line-start</think>that closes one is kept. I did not use the rule #4704 suggests (keep any</think>inside a fence the answer opened), because4077-stray-think-in-a-fenceneeds the opposite: there the fence was opened in the reasoning, and the answer's tracker sees its closing line as an opener.Validation
Passed:
main(870aedd9) and pass here, recover on and off, whole and in pieces of 1 and 7. The corpus cases are added too; the corpus also cuts each specimen at every byte.python -m pytest serveon Linux, Python 3.14: 1242 passed, 14 skipped.write_filecall on Chat, streamed Chat and Responses, 9 of 9.Not run: a model run of this branch.
Limits
</think>in a fenced example with no<think>before it is still dropped (#4077 cannot tell it from the real end of reasoning).🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.