mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #4923] [Engine] A stray backtick in the reasoning hides every tool call that follows it in the paragraph #2260
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#2260
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?
Originally created by @florian862-art on GitHub (Nov 1, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4923
Area
[Engine] (speed, kernels, models, the server and API)
Desktop app, Terminal or source?
Docker
What happened
One unpaired backtick anywhere in the reasoning text makes every tool call that follows it in the same paragraph be
kept as reasoning text instead of being delivered as a call. The client receives a well-formed, complete reply -
the block is closed and
message_delta+message_stoparrive normally - that simply contains thinking only and notool_useblock. An agentic client therefore has nothing to execute and sits in "Thinking" indefinitely, while theengine has already finished the turn.
The inline-code test in
OutputParsercounts backticks across the whole paragraph (self.ticks += line.count("`"), reset only on a blank line). A model that writes one unpaired backtick - a tool name meant asinline code whose closing backtick never arrives - leaves that count odd for the rest of the paragraph, and
_opener_ok()/_in_code()then read every later<tool_call>as quoted inline code.What makes this expensive rather than cosmetic:
finish=stop, the SSE stream is closed properly, and nothing is logged. Theclient just has nothing to act on.
tool_call_recoverydoes not rescue the call (checked below), because the call isnever recognised as a call in the first place.
streaming artefact - whole and streamed outputs agree (see below), so it is not the buffer/flush class of bug.
Suspected path, for the maintainers' convenience: inline code is a one-line matter in the cases that matter here -
a quoted call is written
`<tool_call>`or inside a fence, both of which are already handled by the fencestate and the current line. Carrying the odd count across the rest of the paragraph is what loses the call.
This is the output-side sibling of #1058 (a quoted call being delivered as a real one) and shares
OutputParser'scode tracking with #4702 (fence length) and #4703 (indented blocks). It is not a duplicate of any of them: #4702 is
about a fence being closed too early, here a fence-less inline count is carried too far.
Smallest steps or command that reproduce it
Parser level - no model, no GPU, no server. From the root of a checkout:
Observed on
main(c62d5e3a):Expected: all three
True. A call the model writes at the start of a line, outside a fence and outside inlinecode, is a call. Variant A shows that a closed inline-code span does not suppress the call, so the odd count is
what does the damage. The opposite guarantee - a call the model quotes on purpose (
`<tool_call>`, or insidea fence) must stay text - is #1058's, is covered by
serve/test_tool_corpus.py, and has to keep holding.The same input with
recover=True(the opt-intool_call_recovery) also staysFalsein all four combinations ofrecoverxstream_tools, so no configuration avoids this.Reproduction status
Reproduced locally
Strata version
Strata 0.2.2 (commit
a7689c48) · engine 0.1.47. Reproduced again againstserve/frontend.pyfrommain(
c62d5e3a), which still has the paragraph-wideself.tickscount.Graphics card, memory and system
2x RTX 5070 Ti 16 GB · 91 GB RAM · Linux 7.0.0-38-generic, driver 595.99.02, served in Docker with the source
mounted
Model, size and settings
qwen3.8-flash-next nvfp4 · 262144 context · pictures on · thinking on (thinking budget 12288 of max_tokens 16384) ·
requests over
/v1/messages(Anthropic form) from the Cline clientLogs
The parser repro above is the evidence; there is no useful server log for the failure itself, because the failure
is silent by construction.
s["phase"]is set only from parser events (server.py~4837-4845: atool_calleventis what makes the phase
tool call complete), so a turn lost to this bug never logs a tool-call line at all - itgoes from thinking straight to a normal
done: ... (stop, cancel=False). A healthy turn for comparison:The client-side symptom is a reply that carries reasoning content and ends without a tool call, so the agent never
receives a
tool_useto run. The stream itself is well-formed: the open block is closed andmessage_delta+message_stopare sent (server.py~5814-5828), which is why the client waits rather than errors.A note on the fix, in case it helps
The first rule I tried - carry the open span only when a backtick run ends its line - fixes B and C but is too
narrow: it loses the wrapped span whose closing run ends the line (D1 below). What held up instead pairs the runs
across the paragraph and asks one extra question - whether the last run ended a line:
A fence line's own backticks stay literal, and
_opener_ok()can delegate to_in_code()instead of repeating thelogic. Where the two rules differ:
main`exampleclosed by a run that ends its line, then a callOne case is not recoverable by any rule without lookahead, and it is worth stating because it bounds the fix: "use
run_commands to check." (a stray) and "aspan that stays open" (an unclosed span) are the same shape - onebacktick run, not at the end of the line, nothing closing it later in the paragraph. A parser cannot tell them
apart before the paragraph ends. The rule above resolves it towards delivering the call, which for an agentic client
is the cheaper error: a delivered call is at worst a tool the model did not mean, while a kept-as-text call ends the
turn with nothing to run and the client waits forever.
Verified on
main(c62d5e3a), not just on my older 0.2.2 checkout:serve/test_parser_track.py,test_tool_corpus.py,test_tool_call_unclosed.py,test_native_tool_parser.pyon unpatchedmainmainOne thing any fix has to carry:
serve/test_parser_track.pypinsself.ticksdirectly (itsReferenceParserre-implements the tracking and the state tuples compare it), so the test needs the same state change as the parser -
the 23-test line above is with that adaptation applied.
test_tool_corpus.pyneeded no change; its4077-stray-think-after-a-backtickandqwen-quoted-in-a-fencecases pass as they are.Why the extra "did the last run end a line" question is what makes it work: parity alone is what
mainalreadydoes, and parity alone is exactly what loses B1 - a stray backtick leaves the paragraph odd, so everything after it
reads as code. Asking whether the run that would have opened the span actually ended its line keeps the wrapped
examplereading #1058 pinned (D1, D2) while a run sitting in the middle of a sentence no longer poisons the restof the paragraph.
I am reporting this rather than only carrying a local patch, and I am not presuming the shape of an upstream fix -
the maintainers know what
OutputParserhas to keep guaranteeing.@XiaoBinGan commented on GitHub (Nov 4, 2026):
Thanks for the reproduction — it is the parser, not the model.
serve/frontend.py'sOutputParser._track()counts backticks across the whole paragraph, so one unpaired backtick (Let me use `run_commands to check.) leaves the count odd and every later<tool_call>at the start of a line is read as quoted inline code: the turn completes normally with notool_useblock.I have a pull request with the fix and the issue's three inputs as tests, plus the two shapes that must stay text (`Use `` + a newline, and a backtick immediately before a tag): #5183