mirror of
https://github.com/Niko1221/Strata.git
synced 2026-12-03 19:03:30 +07:00
[GH-ISSUE #3883] [Engine] Tool call returned as plain text (finish stop, no tool_calls): Qwen <tool_call><function=run_command> XML, intermittent #1654
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#1654
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 @Hotzigetty on GitHub (Oct 23, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3883
Problem
Sometimes the model's tool call is returned as ordinary assistant text and the request finishes with
stop. Notool_callsentry is produced, so the client never runs the tool and the turn ends with raw XML on screen. It is intermittent: the same prompt in fresh chats gives a proper tool call on some runs and raw text on others.Environment
strata --version. Also seen on 0.2.2 (build 0.1.47).--kv int8,--vision cpu, port 8080/v1/chat/completions. Tools: Open Terminal (run_command,write_file,list_files) plus Open WebUI's deferred-tool loader (search_tools/call_tool).Reproduce
In a fresh Open WebUI chat with Open Terminal tools enabled, send:
Repeat in fresh chats. About 3 of 5 runs leaked, and the others ran normally.
Expected
The call is returned as
tool_callswithfinish_reason: "tool_calls". If it cannot be parsed, the response should say so and not hand the raw XML back as content.Actual
A short sentence followed directly by the call as text (line breaks not preserved in my screenshot):
The monitor shows one request, finish
stop, 25,642 tokens in, 160 out. There is no follow-up request, so nothing was executed.Evidence
Screenshots attached: (1) first Python run with the Requests row, (2) a leak right after
search_tools, (3) a leak with the built-in tools declared up front, (4) a leak after an image question (python3 -ccall). No raw API response or engine log yet.Observations (not confirmed)(edited)
search_tools/call_toolin the request. When the model then callsrun_commandby name, the tool is not in the request'stools, so declared-only parsing (#3075) returns the call as plain text. I haven't captured thetoolsarray on a leaking request, but with the tools declared in every request, 5 of 5 fresh-chat runs of the Python prompt executed normally. With deferred loading, about 3 of 5 leaked.python -ccommands came back as typed calls in 20 of 20 direct-engine requests, on engine 0.1.48 and on 0.1.50. My earlier suspicion about<<in this section was wrong.cmd,command, pluscwdandwait).</parameter>/</functionfragments and empty replies, which another user reported on Linux, did not appear in my 20 direct requests on Windows.Reproduction status
Reproduced locally on 0.2.3. I have not yet reproduced it with the tool definition sent straight to the engine, with no Open WebUI in between.
@infopointer commented on GitHub (Oct 23, 2026):
Same problem on the DeepSeek Harness
@Tsury commented on GitHub (Oct 24, 2026):
Direct parser check on current
main(8183c6b6, engine 0.1.48), with no Open WebUI in between.I fed the exact
run_commandtext from this report (the heredoccommand,cwdandwait) toserve.frontend.OutputParserwithdeclared_only=True. I tried streaming and non-streaming, in chunks of 1, 5 and 4096 characters.run_commandin the request'stools, every run gives one typed call: the heredoc is kept as written,waitbecomes15, and no XML is left in the content.search_toolsandcall_tooldeclared (the deferred-tool loader case), the call stays text andparser.unread == 1. That is the declared-only rule from #3075, and the server logs it as an unparsed call.So the heredoc and
<<do not break parsing on their own here. A leak right aftersearch_toolsmatches the model calling a tool that the request did not declare. On a leaking request, the server's unparsed-call log line, together with the request'stoolslist, would show which case it is.@Hotzigetty commented on GitHub (Oct 24, 2026):
Thanks for checking the parser directly. That rules out my heredoc /
<<theory, and I'll correct the Observations section in the description.My setup uses Open WebUI's deferred tool loading (
search_tools/call_tool), so your declared-only explanation fits the leaks that came right aftersearch_tools. I have not yet captured the declared tool list on a leaking request. I'll post that and the server's unparsed-call log line here.One thing I can't explain yet: with the same config and prompt, some runs executed
write_fileandrun_commandnormally. I'll check whether those runs went throughcall_tool, which would mean the model sometimes wraps the call and sometimes calls the discovered tool by its own name.If that is what is happening, the fix may belong on the Open WebUI / prompt side. A case where a called-but-undeclared tool returned
tool_callsinstead of text would be a design decision for you, and I understand why #3075 chose declared-only.@cailei695968-png commented on GitHub (Oct 25, 2026):
Direct-engine reproduction of the leak on Linux, with the same script showing two more delivery failures that do not appear in this report or in #4071: arguments that come back with a trailing
</parameter>+</functionfragment glued to the value, and a request that reportsfinish_reason: "stop"withcompletion_tokens: 500–570while the client receives an emptycontentand notool_calls.This answers the open question in the "Observations" section: no Open WebUI, no deferred tool loading, no client-side rewriting. One
POST /v1/chat/completionsstraight toserve/server.py, the requested name declared intools, and the call still fails to arrive.Environment
./engine/strata --version), run from source:serve/server.py --engine strata --config strata-ud-q4_k_xl.json --port 8080--max-context 262144 --kv int8 --spec 4 --mtp ... --kv-grow --conversation-cache-mib 32768 --conversation-cache-slots 8 --expert-profile-save ...--visiontemperature 0.3,max_tokens 2500,chat_template_kwargs: {"enable_thinking": false}, plain non-streamingstream: falseTools declared (both, identically, in every request):
User turn (only the path changes per run): "把一段约500字的《消防管道安装施工方案》正文写入
/opt/data/cache/scratch/sN.txt。" Every run'ssystemprompt carries a unique 4-character marker so no two requests share a conversation-cache prefix.Result — 10 runs, 7 delivered wrong
finish_reasoncompletion_tokenscontentvalue ends with…工程质量。\n\n</parameter>\n</functionobservation\n|contentends with…工程质量。\n</parameter>\n</function观察, parameters>\ncontent: "",tool_calls: []— nothing delivered<tool_call><function=terminal><parameter=command>…returned ascontent(heredoc command, never ran)content: "",tool_calls: []— nothing delivered…文明施工。\n\n</parameter>\n</function.obsidian>\n>…确保施工安全。\n\n</parameter>\n</function观察记录Same prompt shape, same tools, same server process — 3/10 clean. Runs 1, 3, 7, 9 are not the truncation described in #4078: the argument is not cut short, the length is right and the trailing
</parameter></functionfragment (plus 0–12 characters that belong to no part of the request) is appended to the value the client receives.The characters after
</functionare the interesting part —observation,观察, parameters>,.obsidian>,观察记录appear nowhere in the request (no mention of Obsidian, noobservation/parameterswording anywhere in the system prompt, tools, or user turn). Whatever emits them is reading state that does not belong to this conversation.Runs 4 and 6: generated, then dropped
This is the symptom I have not seen reported. Engine log for the same requests:
Client-side, the same two responses are:
500 and 570 tokens were generated, counted and billed in
usage, and the caller got an empty assistant message. Nounreadline is printed for these (parser.unreadstays 0) and no[strata] … did not read as a callline appears — so the failure is silent at every level.The
unreadline does print hereAgainst the same server, a longer agent-shaped request (real tool list, multi-turn history,
max_tokens210K context) produced:None of these lines carried the
; the names the model wrote: …suffix, i.e.parser.unread_nameswas empty even thoughparser.unreadwas 1/1/2 — so the block failed the form test atserve/frontend.py:1400/:1446before a name was ever collected. That makes the log line point at the template/<function=shape rather than at an undeclared name, which is worth knowing since #4071 was closed as unreproducible from the client side.Reproduce
Run it twice: an earlier 6-run pass on the same server gave 1
JUNKout of 6; the 10-run pass above gave the 7 listed. It needs a GPU and the pack, nothing else — no client, no agent framework.What would make this diagnosable
<tool_call>block cannot be delivered as a call, the raw block should come back ascontentwith a counter rather than being dropped (runs 4/6), and theunreadpath should printunread_nameseven when the form test fails atserve/frontend.py:1400— the name is available two lines above.</parameter>/</functionfragment should be stripped at the boundary where the value is closed rather than kept as argument text.</functionwithout its>seems to be the actual shape the model emits here; a strict</function>match leaves that tail inside the value.</function(observation,观察,.obsidian) are what I think they are — state from another request or another cache slot — then the conversation-cache path is worth a look under--conversation-cache-slots 8with near-identical prompts, since the three clean runs and the seven bad ones differ only by that one marker character.@Hotzigetty commented on GitHub (Oct 25, 2026):
Resolved on my side by not deferring tools in Open WebUI: with run_command declared in every request, five fresh-chat runs of the Python prompt all executed normally, where about 3 of 5 leaked with deferred loading. That matches the declared-only rule. Not asking for a parser change; the failure only occurs when the model calls a discovered-but-undeclared tool by name.
@Niko1221 commented on GitHub (Oct 26, 2026):
Glad the declared-only setup works. A tool that is called but not declared in the request stays as text by design, and the recovery for that case is tracked in #3796. cailei695968-png's report in this thread (declared tools, a stray </function fragment glued to the argument, and finish stop with empty content) is a different bug; please open it as its own issue with the 10-run script so we can reproduce it on a model.