Qwen3-Coder <function=NAME> tool-call markup is not parsed, so text-mode tool calls never execute
Prerequisites
- I searched open issues and discussions and did not find an existing report of this bug.
- This is not a security vulnerability. (Vulnerabilities go to GitHub Security Advisories — see SECURITY.md.)
- I am running the latest code from the
devbranch (the default branch you get on clone, where fixes land first) and the bug still reproduces there. Pleasegit pullthe latestdevbefore filing.
Closest existing issues, checked and not duplicates: #5545 is the token-based <|tool_call_start|>[tool(args)]<|tool_call_end|> form, a different dialect from the XML one below. #5192 / #5719 / #5466 cover why Ollama endpoints end up in text mode; this issue is about text mode then being unable to read what the model writes once it is there.
Odysseus Revision
3b6c16916233 (2026-09-14)
Install Method
Native Python (venv)
Operating System
Linux (WSL2, Ubuntu)
Steps to Reproduce
- Add a local Ollama endpoint (
http://127.0.0.1:11434/v1) — the text-mode path described in #5719. - Select a qwen-architecture model. Reproduced with
ornith-1.5:9b(architecture qwen35). - Agent mode, Shell access on.
- Ask:
Run this shell command and show me the output: echo HELLO. - The assistant announces the command, the markup renders as chat text, and no tool runs.
Or directly, without the app:
from src.agent_tools import parse_tool_blocks
print(parse_tool_blocks(
"<tool_call>\n<function=bash>\n<parameter=command>\necho hello\n</parameter>\n</function>\n</tool_call>"
))
# [] ← expected one bash blockExpected Behaviour
parse_tool_blocks recognises the Qwen3-Coder call format and returns one executable block, the same way it handles the Hermes-JSON and <invoke name=…> dialects.
Actual Behaviour
Zero blocks. Qwen-architecture models emit their native Qwen3-Coder format, which puts the names in the tag rather than in a name attribute:
<tool_call>
<function=bash>
<parameter=command>
echo hello
</parameter>
</function>
</tool_call>src/tool_parsing.py has no handler for it, so the call renders as plain text and nothing executes. Comparison against the supported dialects, same input shape:
| dialect | blocks |
|---|---|
<tool_call>{"name": "bash", "arguments": {…}}</tool_call> |
1 |
<tool_call><invoke name="bash"><parameter name="command">… |
1 |
<tool_call><function=bash><parameter=command>… |
0 |
One detail worth separating, because it looks like the cause and is not: real output from these models also contains a stray empty <function></function> pair right after the opening tag. That is not why parsing fails — the canonical form above, with no stray tag, also returns zero. It does matter for the fix, though: it is the first closer in the body, so a forward-only scan pairs the opener with it and finds no parameters.
Logs / Screenshots
src.agent_loop - INFO - Agent round 1 summary: 160 chars, 0 native calls, 0 tool blocks.Recovered five real assistant messages using this dialect from a live data/app.db (two web_search, one ui_control, two bash). All five returned zero blocks.
The model itself is fine — given native schemas it returns a clean structured call in 271 prompt tokens:
curl -s http://127.0.0.1:11434/api/chat -d '{
"model":"ornith-1.5:9b",
"messages":[{"role":"user","content":"Run: echo HELLO"}],
"tools":[{"type":"function","function":{"name":"bash",
"parameters":{"type":"object","properties":{"command":{"type":"string"}},
"required":["command"]}}}],
"stream":false}'
# -> message.tool_calls[0].function = {"name":"bash","arguments":{"command":"echo HELLO"}}So on a local Ollama endpoint the model is competent at tool calling by either route, and neither route reaches execution: native schemas are off (#5719, #5192), and the text form it falls back to is unreadable (this issue).
Model / Backend (if relevant)
Ollama 0.33.3, ornith-1.5:9b (qwen35, Q4_K_M). Applies to any qwen-architecture model on a text-mode endpoint.
Are you willing to submit a fix?
Yes — it is written and tested, happy to open a PR.
Approach: rather than adding a fifth parser branch and wiring it into four call sites, normalize <function=NAME> / <parameter=KEY> into the already-supported <invoke name=…> / <parameter name=…> form up front — the same approach _normalize_dsml already uses for DeepSeek markup. One function, called beside _normalize_dsml in both parse_tool_blocks and strip_tool_blocks; every downstream path then works unchanged, including the unclosed-wrapper handling and the strip path. 27 lines in src/tool_parsing.py.
Scanning reuses the file's existing ReDoS-safe primitives, so the tests/test_redos_xml_tool_parsers.py constraint holds by construction — the added patterns have no nested quantifiers.
Tests: 7 new cases in tests/test_tool_parsing_qwen_function_xml.py, written first and watched fail, including the verbatim stray-tag output from a real chat. Full suite on dev: 5,934 passed, 4 skipped. Verified end to end in a running instance — the agent parsed the block, requested approval, and src.tool_execution logged bash: echo … -> exit_code=0.
Additional Information
Note for whoever picks this up: once the dialect parses, a model that explains this syntax inside a markdown fence produces an executable block. That behaviour is pre-existing and identical for <invoke> — it is #3604, not something this change introduces — but it does widen that surface by one dialect.
Source: odysseus-dev/odysseus