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#5110
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/4613
Author: @james-martinez
Created: 10/29/2026
Status: 🔄 Open
Base:
main← Head:f-4071-fenced-reject-marker📝 Commits (1)
f9ad906serve: a call-shaped block inside a code fence is counted and named too (#4071)📊 Changes
4 files changed (+161 additions, -8 deletions)
View changed files
📝
docs/DETAILS.md(+3 -2)📝
serve/frontend.py(+37 -4)📝
serve/server.py(+6 -2)➕
serve/test_unread_call_marker.py(+115 -0)📄 Description
Problem and result
A Chat Completions request that declares no tools (or none matching what the model writes) gets an answer ending in a complete, well-formed
<tool_call>block inside a Markdown code fence — what Open WebUI shows as "the tool XML appeared inside a code block".tool_callsis empty,finish_reasonisstop, and the chat stores the markup as text.The rules that keep such a block as text both stay (declared-only #3075, code fence #1058); the reply text and
finish_reasonare unchanged. What changes is visibility: the fence path used to pass the block back without counting it at all, so a client could not distinguish "the model wrote a call and the parser dropped it" from "the model chose not to call". After this commit the fenced/inline-code block is counted and named like the other paths, andstrata_rejected_tool_callsentries carry areason.Reproduced locally (not static analysis):
write_fileblock in a ```xml fence incontent, notool_calls,finish_reason: stop; parser stateunread=0, unread_names=[]— invisible to every signal #3796 added.main(46c152a): the shape inserve/test_unread_call_marker.py::FencedBlockIsCountedfails on stock main (leak withunread=0), passes with this commit.Related discussion
#4071 (this is the fenced variant of the reported failure), #3796 (the marker this completes), #3075/#1058 (the rules kept). No prior scope discussion needed per CONTRIBUTING ("focused fixes can go straight to a PR"); datapoint posted in #4071.
Approach
OutputParser's fence / inline-code branch now runs the block through a shared_mark_unread(): it counts once and names once the function name has fully arrived (a partial name is held like a partial tag, so streamed and whole outputs count identically — checked at chunk sizes 1/3/17). Reasons:undeclared,in_code(a declared name quoted inside code),malformed(an opener with no readable name; counted as before, still unnamed, so the existing "malformed blocks have no name to list" contract is preserved). The two existingunread += 1sites route through the same helper.serve/server.pyforwards the reasons instrata_rejected_tool_calls; the stdout warning andtool_calls_unreadcounter are unchanged apart from now including fenced blocks, which is what that counter was meant to measure. The Anthropic route sharesOutputParser, so/v1/messagesfenced blocks gain the same marker the JSON route already had for undeclared names. Nothing undeclared becomes a call; quoted examples stay quoted; prose that merely names the tag stays clean (test-covered).Validation
Python-only change in
serve/; no engine code touched. Python 3.12, Linux x86_64.Passed:
python -m unittest serve.test_unread_call_markerat this commit: 7 tests, OK. Same file on a pristinemain(46c152a) worktree: fails (fenced block leaks withunread=0/ nounread_info), confirming the regression test captures the bug.python -m pytest serve/test_frontend.py serve/test_parser_hold.py serve/test_parser_track.py serve/test_reasoning_rescue.py serve/test_parser_call_scan.py serve/test_tool_call_envelope.py serve/test_reasoning_tools.py serve/test_tool_name_alias.py serve/test_unread_call_marker.py: the FAILED list is byte-identical before and after this commit (diff of the sorted FAILED sets is empty).serve/test_server.py -k "reject or unread": identical results before and after (see Failed).Failed (pre-existing on pristine main, environment-bound, not caused by this change):
ForcedToolChoice::*,OverHttp::*) that require built engine binaries; this container has no engine build. Identical set on the pristine checkout.Not run:
Limits
unread_infokeeps the same first-five cap asunread_names.tool_calls_unread, so/metricscounts move for shapes that were previously silent — intended, but consumers comparing pre/post dashboards should know.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.