[GH-ISSUE #3883] [Engine] Tool call returned as plain text (finish stop, no tool_calls): Qwen <tool_call><function=run_command> XML, intermittent #1654

Closed
opened 2026-11-04 01:52:57 +07:00 by bsakaguchi · 6 comments
Owner

Originally created by @Hotzigetty on GitHub (Oct 23, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/3883

Image Image Image Image

Problem

Sometimes the model's tool call is returned as ordinary assistant text and the request finishes with stop. No tool_calls entry 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: 0.2.3 (build 0.1.48), from strata --version. Also seen on 0.2.2 (build 0.1.47).
  • Engine package: windows-x86_64-cuda-cuda13
  • OS / hardware: Windows 11, RTX 5060 Ti 16 GB, i5-14400F, 64 GB RAM
  • Model / settings: Swift 1.5 IQ2_XS, 200K context, --kv int8, --vision cpu, port 8080
  • Client: Open WebUI with native function calling, via /v1/chat/completions. Tools: Open Terminal (run_command, write_file, list_files) plus Open WebUI's deferred-tool loader (search_tools / call_tool).
  • Sampling sent by Open WebUI: temperature 0.6, top_p 0.95, top_k 20.

Reproduce

In a fresh Open WebUI chat with Open Terminal tools enabled, send:

Use Python to work out how many times faster 0.5 s is than 11.0 s, and print it with a line of explanation.

Repeat in fresh chats. About 3 of 5 runs leaked, and the others ran normally.

Expected

The call is returned as tool_calls with finish_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):

<tool_call> <function=run_command> <parameter=command> mkdir -p speedup_calc && cat > speedup_calc/speedup.py <<'EOF' slow = 11.0 fast = 0.5 speedup = slow / fast print(f"A {fast} s task is {speedup:.1f}x faster than an {slow} s task.") EOF python3 speedup_calc/speedup.py </parameter> <parameter=cwd> /home/dexter-workspace </parameter> <parameter=wait> 15 </parameter> </function> </tool_call>

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 -c call). No raw API response or engine log yet.

Observations (not confirmed)(edited)

  • Most likely cause: Open WebUI's deferred tool loading declares only search_tools / call_tool in the request. When the model then calls run_command by name, the tool is not in the request's tools, so declared-only parsing (#3075) returns the call as plain text. I haven't captured the tools array 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.
  • The argument text is not the cause. With the tool declared, heredocs and multi-line python -c commands 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.
  • Argument names varied between leaks (cmd, command, plus cwd and wait).
  • Trailing </parameter> / </function fragments and empty replies, which another user reported on Linux, did not appear in my 20 direct requests on Windows.
  • Workaround: do not defer tools in Open WebUI.

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.

Originally created by @Hotzigetty on GitHub (Oct 23, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/3883 <img width="1268" height="757" alt="Image" src="https://github.com/user-attachments/assets/3cf046fa-a9e9-44a6-a4c8-0f2ad8233d3a" /> <img width="1232" height="754" alt="Image" src="https://github.com/user-attachments/assets/1e11a9a3-6faf-4d0e-9ba0-226099f4be68" /> <img width="1185" height="758" alt="Image" src="https://github.com/user-attachments/assets/d8fd8a3e-5e66-4653-8f7d-66a68e62aacc" /> <img width="1286" height="637" alt="Image" src="https://github.com/user-attachments/assets/ea556565-fdf5-4163-ba1d-515033a5e1a0" /> ## Problem Sometimes the model's tool call is returned as ordinary assistant text and the request finishes with `stop`. No `tool_calls` entry 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:** 0.2.3 (build 0.1.48), from `strata --version`. Also seen on 0.2.2 (build 0.1.47). - Engine package: windows-x86_64-cuda-cuda13 - OS / hardware: Windows 11, RTX 5060 Ti 16 GB, i5-14400F, 64 GB RAM - Model / settings: Swift 1.5 IQ2_XS, 200K context, `--kv int8`, `--vision cpu`, port 8080 - Client: Open WebUI with native function calling, via `/v1/chat/completions`. Tools: Open Terminal (`run_command`, `write_file`, `list_files`) plus Open WebUI's deferred-tool loader (`search_tools` / `call_tool`). - Sampling sent by Open WebUI: temperature 0.6, top_p 0.95, top_k 20. ## Reproduce In a fresh Open WebUI chat with Open Terminal tools enabled, send: > Use Python to work out how many times faster 0.5 s is than 11.0 s, and print it with a line of explanation. Repeat in fresh chats. About 3 of 5 runs leaked, and the others ran normally. ## Expected The call is returned as `tool_calls` with `finish_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): ``` <tool_call> <function=run_command> <parameter=command> mkdir -p speedup_calc && cat > speedup_calc/speedup.py <<'EOF' slow = 11.0 fast = 0.5 speedup = slow / fast print(f"A {fast} s task is {speedup:.1f}x faster than an {slow} s task.") EOF python3 speedup_calc/speedup.py </parameter> <parameter=cwd> /home/dexter-workspace </parameter> <parameter=wait> 15 </parameter> </function> </tool_call> ``` 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 -c` call). No raw API response or engine log yet. ## Observations (not confirmed)(edited) - Most likely cause: Open WebUI's deferred tool loading declares only `search_tools` / `call_tool` in the request. When the model then calls `run_command` by name, the tool is not in the request's `tools`, so declared-only parsing (#3075) returns the call as plain text. I haven't captured the `tools` array 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. - The argument text is not the cause. With the tool declared, heredocs and multi-line `python -c` commands 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. - Argument names varied between leaks (`cmd`, `command`, plus `cwd` and `wait`). - Trailing `</parameter>` / `</function` fragments and empty replies, which another user reported on Linux, did not appear in my 20 direct requests on Windows. - Workaround: do not defer tools in Open WebUI. ## 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.
Author
Owner

@infopointer commented on GitHub (Oct 23, 2026):

Same problem on the DeepSeek Harness

All four pages check out. Here's the final result:

<tool_call> <function=present> <parameter=files> [{"path": "landing-pages/saas-analytics/index.html", "description": "Pulseboard — dark-theme SaaS analytics landing page"}, {"path": "landing-pages/coffee-shop/index.html", "description": "Ember & Oak Roasters — warm artisan coffee shop landing page"}, {"path": "landing-pages/mobile-app/index.html", "description": "Streakly — habit-tracking app launch page"}, {"path": "landing-pages/fitness-gym/index.html", "description": "Ironleaf Athletic Club — bold fitness studio landing page"}] </tool_call>

<!-- gh-comment-id:6375181514 --> @infopointer commented on GitHub (Oct 23, 2026): Same problem on the DeepSeek Harness > All four pages check out. Here's the final result: > > <tool_call> <function=present> <parameter=files> [{"path": "landing-pages/saas-analytics/index.html", "description": "Pulseboard — dark-theme SaaS analytics landing page"}, {"path": "landing-pages/coffee-shop/index.html", "description": "Ember & Oak Roasters — warm artisan coffee shop landing page"}, {"path": "landing-pages/mobile-app/index.html", "description": "Streakly — habit-tracking app launch page"}, {"path": "landing-pages/fitness-gym/index.html", "description": "Ironleaf Athletic Club — bold fitness studio landing page"}] </parameter> </function> </tool_call>
Author
Owner

@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_command text from this report (the heredoc command, cwd and wait) to serve.frontend.OutputParser with declared_only=True. I tried streaming and non-streaming, in chunks of 1, 5 and 4096 characters.

  • With run_command in the request's tools, every run gives one typed call: the heredoc is kept as written, wait becomes 15, and no XML is left in the content.
  • With only search_tools and call_tool declared (the deferred-tool loader case), the call stays text and parser.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 after search_tools matches 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's tools list, would show which case it is.

<!-- gh-comment-id:6381410490 --> @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_command` text from this report (the heredoc `command`, `cwd` and `wait`) to `serve.frontend.OutputParser` with `declared_only=True`. I tried streaming and non-streaming, in chunks of 1, 5 and 4096 characters. - With `run_command` in the request's `tools`, every run gives one typed call: the heredoc is kept as written, `wait` becomes `15`, and no XML is left in the content. - With only `search_tools` and `call_tool` declared (the deferred-tool loader case), the call stays text and `parser.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 after `search_tools` matches 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's `tools` list, would show which case it is.
Author
Owner

@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 after search_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_file and run_command normally. I'll check whether those runs went through call_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_calls instead of text would be a design decision for you, and I understand why #3075 chose declared-only.

<!-- gh-comment-id:6381513304 --> @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 after `search_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_file` and `run_command` normally. I'll check whether those runs went through `call_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_calls` instead of text would be a design decision for you, and I understand why #3075 chose declared-only.
Author
Owner

@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> + </function fragment glued to the value, and a request that reports finish_reason: "stop" with completion_tokens: 500–570 while the client receives an empty content and no tool_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/completions straight to serve/server.py, the requested name declared in tools, and the call still fails to arrive.

Environment

  • Strata 0.2.3, engine 0.1.48 (./engine/strata --version), run from source: serve/server.py --engine strata --config strata-ud-q4_k_xl.json --port 8080
  • Engine flags in play: --max-context 262144 --kv int8 --spec 4 --mtp ... --kv-grow --conversation-cache-mib 32768 --conversation-cache-slots 8 --expert-profile-save ...
  • Ubuntu 26.04, RTX 5090 32 GB, model Qwen3.8-Flash-Next-UD-Q4_K_XL (4 shards), --vision
  • Request: temperature 0.3, max_tokens 2500, chat_template_kwargs: {"enable_thinking": false}, plain non-streaming stream: false

Tools declared (both, identically, in every request):

[{"type":"function","function":{"name":"write_file","description":"Write content to a file",
  "parameters":{"type":"object","properties":{"path":{"type":"string"},"content":{"type":"string"}},
  "required":["path","content"]}}},
 {"type":"function","function":{"name":"terminal","description":"Run a shell command",
  "parameters":{"type":"object","properties":{"command":{"type":"string"}},"required":["command"]}}}]

User turn (only the path changes per run): "把一段约500字的《消防管道安装施工方案》正文写入 /opt/data/cache/scratch/sN.txt。" Every run's system prompt carries a unique 4-character marker so no two requests share a conversation-cache prefix.

Result — 10 runs, 7 delivered wrong

run finish_reason completion_tokens what the client got
0 tool_calls — OK
1 tool_calls 563 content value ends with …工程质量。\n\n</parameter>\n</function observation\n|
2 tool_calls — OK
3 tool_calls 536 content ends with …工程质量。\n</parameter>\n</function 观察, parameters>\n
4 stop 500 content: "", tool_calls: [] — nothing delivered
5 stop 598 whole <tool_call><function=terminal><parameter=command>… returned as content (heredoc command, never ran)
6 stop 570 content: "", tool_calls: [] — nothing delivered
7 tool_calls 555 …文明施工。\n\n</parameter>\n</function .obsidian>\n>
8 tool_calls — OK
9 tool_calls 560 …确保施工安全。\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> </function fragment (plus 0–12 characters that belong to no part of the request) is appended to the value the client receives.

The characters after </function are the interesting part — observation, 观察, parameters>, .obsidian>, 观察记录 appear nowhere in the request (no mention of Obsidian, no observation/parameters wording 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:

[strata] done: 500 tokens in 4 s (158.7 tok/s) (stop, cancel=False), expert cache 95.3% hit (+0.3% of the routed experts over PCIe)
[strata] done: 570 tokens in 4 s (160.8 tok/s) (stop, cancel=False), expert cache 95.3% hit (+0.2% of the routed experts over PCIe)

Client-side, the same two responses are:

{"choices":[{"index":0,"finish_reason":"stop","message":{"role":"assistant","content":""}}],
 "usage":{"completion_tokens":500, ...}}

500 and 570 tokens were generated, counted and billed in usage, and the caller got an empty assistant message. No unread line is printed for these (parser.unread stays 0) and no [strata] … did not read as a call line appears — so the failure is silent at every level.

The unread line does print here

Against the same server, a longer agent-shaped request (real tool list, multi-turn history, max_tokens 210K context) produced:

[strata] 1 <tool_call> block(s) in the answer did not read as a call of a declared tool and went back as text (a name the request did not declare, or a form the template does not use)
[strata] 1 <tool_call> block(s) in the answer did not read as a call of a declared tool and went back as text (a name the request did not declare, or a form the template does not use)
[strata] 2 <tool_call> block(s) in the answer did not read as a call of a declared tool and went back as text (a name the request did not declare, or a form the template does not use)

None of these lines carried the ; the names the model wrote: … suffix, i.e. parser.unread_names was empty even though parser.unread was 1/1/2 — so the block failed the form test at serve/frontend.py:1400 / :1446 before 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

import json, os, urllib.request
URL = "http://<host>:8080/v1/chat/completions"
KEY = os.environ["STRATA_API_KEY"]          # --api-key of the server
TOOLS = [ ...the two declarations above... ]
JUNK  = ("</parameter>", "</function", "</tool_call>", "<tool_call>", "<function=")
for i in range(10):
    msgs = [{"role": "system", "content": "你是投标文件编制助手。轮次:%d" % i},
            {"role": "user",   "content": "把一段约500字的《消防管道安装施工方案》正文写入 /tmp/s%d.txt。" % i}]
    body = {"model": "strata", "messages": msgs, "tools": TOOLS, "max_tokens": 2500,
            "temperature": 0.3, "chat_template_kwargs": {"enable_thinking": False}}
    req = urllib.request.Request(URL, data=json.dumps(body).encode(),
            headers={"Content-Type": "application/json", "Authorization": "Bearer " + KEY})
    d = json.load(urllib.request.urlopen(req, timeout=180))
    m = d["choices"][0]["message"]; tc = m.get("tool_calls") or []
    if not tc:
        print(i, "NO_TOOL", d["choices"][0]["finish_reason"], d["usage"]["completion_tokens"], repr((m.get("content") or "")[:80]))
        continue
    v = json.loads(tc[0]["function"]["arguments"]).get("content", "")
    bad = [j for j in JUNK if j in v]
    print(i, "JUNK" if bad else "OK", bad, repr(v[-70:]))

Run it twice: an earlier 6-run pass on the same server gave 1 JUNK out 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

  • When a <tool_call> block cannot be delivered as a call, the raw block should come back as content with a counter rather than being dropped (runs 4/6), and the unread path should print unread_names even when the form test fails at serve/frontend.py:1400 — the name is available two lines above.
  • On the value side, a trailing </parameter> / </function fragment should be stripped at the boundary where the value is closed rather than kept as argument text. </function without its > seems to be the actual shape the model emits here; a strict </function> match leaves that tail inside the value.
  • If the characters after </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 8 with near-identical prompts, since the three clean runs and the seven bad ones differ only by that one marker character.
<!-- gh-comment-id:6398722940 --> @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>` + `</function` fragment glued to the value, and a request that reports `finish_reason: "stop"` with `completion_tokens: 500–570` while the client receives an **empty** `content` *and* no `tool_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/completions` straight to `serve/server.py`, the requested name declared in `tools`, and the call still fails to arrive. ## Environment - Strata **0.2.3**, engine **0.1.48** (`./engine/strata --version`), run from source: `serve/server.py --engine strata --config strata-ud-q4_k_xl.json --port 8080` - Engine flags in play: `--max-context 262144 --kv int8 --spec 4 --mtp ... --kv-grow --conversation-cache-mib 32768 --conversation-cache-slots 8 --expert-profile-save ...` - Ubuntu 26.04, RTX 5090 32 GB, model **Qwen3.8-Flash-Next-UD-Q4_K_XL** (4 shards), `--vision` - Request: `temperature 0.3`, `max_tokens 2500`, `chat_template_kwargs: {"enable_thinking": false}`, plain non-streaming `stream: false` Tools declared (both, identically, in every request): ```json [{"type":"function","function":{"name":"write_file","description":"Write content to a file", "parameters":{"type":"object","properties":{"path":{"type":"string"},"content":{"type":"string"}}, "required":["path","content"]}}}, {"type":"function","function":{"name":"terminal","description":"Run a shell command", "parameters":{"type":"object","properties":{"command":{"type":"string"}},"required":["command"]}}}] ``` User turn (only the path changes per run): *"把一段约500字的《消防管道安装施工方案》正文写入 `/opt/data/cache/scratch/sN.txt`。"* Every run's `system` prompt carries a unique 4-character marker so no two requests share a conversation-cache prefix. ## Result — 10 runs, 7 delivered wrong | run | `finish_reason` | `completion_tokens` | what the client got | |----|----|----|----| | 0 | tool_calls | — | OK | | 1 | tool_calls | 563 | `content` value ends with `…工程质量。\n\n</parameter>\n</function` **` observation\n\|`** | | 2 | tool_calls | — | OK | | 3 | tool_calls | 536 | `content` ends with `…工程质量。\n</parameter>\n</function` **`观察, parameters>\n`** | | 4 | **stop** | **500** | `content: ""`, `tool_calls: []` — **nothing delivered** | | 5 | stop | 598 | whole `<tool_call><function=terminal><parameter=command>…` returned as `content` (heredoc command, never ran) | | 6 | **stop** | **570** | `content: ""`, `tool_calls: []` — **nothing delivered** | | 7 | tool_calls | 555 | `…文明施工。\n\n</parameter>\n</function` **`.obsidian>\n>`** | | 8 | tool_calls | — | OK | | 9 | tool_calls | 560 | `…确保施工安全。\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>` `</function` fragment (plus 0–12 characters that belong to no part of the request) is appended to the value the client receives. The characters after `</function` are the interesting part — `observation`, `观察, parameters>`, `.obsidian>`, `观察记录` appear nowhere in the request (no mention of Obsidian, no `observation`/`parameters` wording 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: ``` [strata] done: 500 tokens in 4 s (158.7 tok/s) (stop, cancel=False), expert cache 95.3% hit (+0.3% of the routed experts over PCIe) [strata] done: 570 tokens in 4 s (160.8 tok/s) (stop, cancel=False), expert cache 95.3% hit (+0.2% of the routed experts over PCIe) ``` Client-side, the same two responses are: ```json {"choices":[{"index":0,"finish_reason":"stop","message":{"role":"assistant","content":""}}], "usage":{"completion_tokens":500, ...}} ``` 500 and 570 tokens were generated, counted and billed in `usage`, and the caller got an empty assistant message. No `unread` line is printed for these (`parser.unread` stays 0) and no `[strata] … did not read as a call` line appears — so the failure is silent at every level. ## The `unread` line does print here Against the same server, a longer agent-shaped request (real tool list, multi-turn history, `max_tokens` 210K context) produced: ``` [strata] 1 <tool_call> block(s) in the answer did not read as a call of a declared tool and went back as text (a name the request did not declare, or a form the template does not use) [strata] 1 <tool_call> block(s) in the answer did not read as a call of a declared tool and went back as text (a name the request did not declare, or a form the template does not use) [strata] 2 <tool_call> block(s) in the answer did not read as a call of a declared tool and went back as text (a name the request did not declare, or a form the template does not use) ``` None of these lines carried the `; the names the model wrote: …` suffix, i.e. `parser.unread_names` was empty even though `parser.unread` was 1/1/2 — so the block failed the *form* test at `serve/frontend.py:1400` / `:1446` before 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 ```python import json, os, urllib.request URL = "http://<host>:8080/v1/chat/completions" KEY = os.environ["STRATA_API_KEY"] # --api-key of the server TOOLS = [ ...the two declarations above... ] JUNK = ("</parameter>", "</function", "</tool_call>", "<tool_call>", "<function=") for i in range(10): msgs = [{"role": "system", "content": "你是投标文件编制助手。轮次:%d" % i}, {"role": "user", "content": "把一段约500字的《消防管道安装施工方案》正文写入 /tmp/s%d.txt。" % i}] body = {"model": "strata", "messages": msgs, "tools": TOOLS, "max_tokens": 2500, "temperature": 0.3, "chat_template_kwargs": {"enable_thinking": False}} req = urllib.request.Request(URL, data=json.dumps(body).encode(), headers={"Content-Type": "application/json", "Authorization": "Bearer " + KEY}) d = json.load(urllib.request.urlopen(req, timeout=180)) m = d["choices"][0]["message"]; tc = m.get("tool_calls") or [] if not tc: print(i, "NO_TOOL", d["choices"][0]["finish_reason"], d["usage"]["completion_tokens"], repr((m.get("content") or "")[:80])) continue v = json.loads(tc[0]["function"]["arguments"]).get("content", "") bad = [j for j in JUNK if j in v] print(i, "JUNK" if bad else "OK", bad, repr(v[-70:])) ``` Run it twice: an earlier 6-run pass on the same server gave 1 `JUNK` out 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 - When a `<tool_call>` block cannot be delivered as a call, the raw block should come back as `content` **with a counter** rather than being dropped (runs 4/6), and the `unread` path should print `unread_names` even when the form test fails at `serve/frontend.py:1400` — the name is available two lines above. - On the value side, a trailing `</parameter>` / `</function` fragment should be stripped at the boundary where the value is closed rather than kept as argument text. `</function` **without its `>`** seems to be the actual shape the model emits here; a strict `</function>` match leaves that tail inside the value. - If the characters after `</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 8` with near-identical prompts, since the three clean runs and the seven bad ones differ only by that one marker character.
Author
Owner

@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.

<!-- gh-comment-id:6403407533 --> @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.
Author
Owner

@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.

<!-- gh-comment-id:6423282571 --> @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 </parameter></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.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#1654
No description provided.