mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
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#5335
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/5183
Author: @XiaoBinGan
Created: 11/4/2026
Status: 🔄 Open
Base:
main← Head:reserve/fix-parser-stray-backtick📝 Commits (1)
0b5afe8[Engine] tool parser: one stray backtick no longer hides the rest of the paragraph's calls (#4923)📊 Changes
3 files changed (+90 additions, -5 deletions)
View changed files
📝
serve/frontend.py(+13 -4)➕
serve/test_parser_stray_backtick.py(+72 -0)📝
serve/test_parser_track.py(+5 -1)📄 Description
Problem and result
The inline-code bookkeeping in
serve/frontend.py'sOutputParsercounted backticks across the whole paragraph:self.ticks += line.count("")`, reset only on a blank line. A model that wrote a tool name as inline code and neverclosed it 鈥?
鈥?left the count odd for the rest of the paragraph, and
_opener_ok()/_in_code()then read every later<tool_call>at the start of a line as quoted inline code. The call was kept as reasoning text, the block was closednormally, and the client got a well-formed, complete reply with no
tool_useblock: an agentic client has nothingto run and waits forever while the engine has already finished the turn. Silent, model-independent, and no
configuration avoids it (
tool_call_recoveryincluded).After the change the call is delivered. From the reproduction in the issue, against
mainc62d5e3aand against thisbranch (the exact script is the issue's "Smallest steps" block):
Related discussion
#4923 鈥?the report, with the parser-level reproduction and the note that the same paragraph-wide count is on
main(
serve/frontend.py,_track/_opener_ok/_in_code). It is the output-side sibling of #1058 (a quoted calldelivered as real); #1058's guarantee has to keep holding, and does (see below).
Approach
One rule: an unmatched backtick followed by prose on its line (
"Let me userun_commands to check."`) is astray marker, not the opening of a code span that crosses the newline. It is not carried into the next line:
The two shapes the existing controls keep as text are untouched:
"Use"and the example on the next line 鈥?test_the_reporters_negative_controls
'check("Use\n" + RM, 0), andtest_quoted_calls_stay_text's"Usex, then\n" + RM):after` isempty there, so the span still crosses the newline;
"Use<tool_call>here."):afterstarts with<, so the span stillopens and the quoted call stays text.
A call inside a one-line inline span (
"The format is<tool_call>...and nothing else.") and inside a fence keepsfollowing the current-line/fence rules unchanged.
_opener_ok()and_in_code()keep their existing formulas; only what_track()records changed. The acknowledgedstreaming/whole-consistency rule also holds:
serve/test_parser_track.py's reference implementation and itsfragment/random-boundary property tests were updated with the same rule, so every streamed fragment produces the
same tracking state as before.
Validation
Passed: the new regression test,
serve/test_parser_stray_backtick.py(4 tests, 7 subtests):It covers the issue's three inputs (paired inline code, one stray backtick, a stray on an earlier line) whole and
streamed in 1- and 7-character pieces and with
recover=True, plus the two negative controls: a backtick at the endof its line still opens the span (text, not a call), a one-line inline quote stays text, a fenced call stays text.
Passed: the A/B 鈥?with
serve/frontend.pyreverted tomain, the same new test fails on the two stray-backtickinputs:
Passed: the surrounding parser and tool-call suites (this checkout, Windows 11, Python 3.11.16):
serve/test_reasoning_rescue.pyincludes the #804/#1058 controls, the 37-specimen corpus (whole and in chunks) andthe three HTTP APIs;
serve/test_tool_corpus.pyholds the quoted-call corpus. All pass on this branch.Failed: none.
Not run: a real model emitting the stray backtick inside a thinking block on served hardware 鈥?the parser-level
reproduction in the issue is what was reproduced, not an end-to-end GPU run.
python -m pytest serve(the wholedirectory) was not completed on this box: it does not finish here within several minutes, so the tool-call and
reasoning files above were run one by one. No engine build is touched: this is the Python server only.
Limits
the next line (
"Userun_commandsthen the example"with the backtick closed on the same line) stillcounts; only a line ending with prose after an unmatched backtick is treated as stray. A span genuinely opened
mid-sentence and closed on a later line is no longer treated as inline code 鈥?that shape is the one that was
swallowing the calls, and no test in the tree asserts it.
Use<tool_call>``controls), so a stray ` before a real call on the next line would still hide that call. That is the #1058 case and
is unchanged on purpose.
needs the existing fence / one-line inline-code / `Use `` shapes to stay text, as above.
Note on the base: this branch was rebuilt on
ffa80d73(0.2.10) after the release;serve/frontend.pykeeps the 0.2.10 additions (_tool_references,_close_verdict) and only gains the stray-backtick rule, and the tests below were run on that rebuilt head.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.