[GH-ISSUE #2451] ### More data for #1431: wrong parameter syntax inside an otherwise valid call (Coder IQ1_M on an Arc Pro B60) #996

Closed
opened 2026-11-04 01:47:35 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @mbaaku on GitHub (Oct 14, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/2451

Hardware note: this is an Intel Arc Pro B60 (bmg-g21, SYCL backend, built with AOT=bmg-g21). The startup banner says the SYCL backend was tested on an Arc Pro B70 and an Arc A750, so the B60 counts as untested. I have no B70 or CUDA card to check whether the rate is backend-specific, so treat that as an open question.

Setup

  • Strata v0.1.44.1 (296b59d), SYCL backend, 1× Intel Arc Pro B60 (24 GB), Debian Linux 13 , Docker 29.8.1 (ONEAPI_DEVICE_SELECTOR=level_zero:0, STRATA_EXPERT_SPLIT=1)
  • Model: Qwen3.8-Flash-Next Coder IQ1_M (--kv int8, --max-context 131072, 1 slot)
  • Run config: "tool_call_recovery": true, "fit_max_tokens": true; reasoning effort left at the model default
  • Client: Continue CLI (cn) through LiteLLM, OpenAI chat completions, streaming, 21 tools (built-in Bash, Read, List, … plus MCP tools)
  • Raw outputs captured with STRATA_DEBUG=1
Full configuration (compose environment, .env, setup command, engine arguments, run config)

compose.yaml, service strata (image built from the repo's Dockerfile.b60), environment:

environment:
  STRATA_DEBUG: "1"
  AOT: bmg-g21
  REPO: ${STRATA_ROOT}/Strata
  BUILD_DIR: ${STRATA_ROOT}/Strata/build-sycl-aot
  JOBS: "28"
  STRATA_EXPERT_SPLIT: "1"

  ONEAPI_DEVICE_SELECTOR: level_zero:0
  SYCL_CACHE_PERSISTENT: "0"
  ZES_ENABLE_SYSMAN: "1"

  STRATA_SYCL_ROOT: ${STRATA_ROOT}
  STRATA_SYCL_IMAGE: strata-sycl-b60

  STRATA_VERIFY_DEVICE_PLAN: "1"
  STRATA_VERIFY_NO_HOST: "1"
  STRATA_MIRROR_MIB: "36864"

.env next to compose.yaml (STRATA_ROOT and STRATA_API_KEY omitted; the commented lines are the other quants used on the same setup):

#STRATA_MODEL=IQ3_S
#STRATA_MODEL=UD-IQ4_XS
STRATA_MODEL=IQ1_M
#STRATA_FAMILY=qwen
#STRATA_FAMILY=unsloth
STRATA_FAMILY=coder
STRATA_CONTEXT=131072

Container command (after an incremental SYCL build when the checked-out commit changed):

exec ./setup.sh \
  --backend sycl \
  --family ${STRATA_FAMILY} \
  --model ${STRATA_MODEL} \
  --gguf-dir "${STRATA_ROOT}/models/${STRATA_MODEL}" \
  --models-dir "${STRATA_ROOT}/models" \
  --data-dir "${STRATA_ROOT}/data" \
  --context ${STRATA_CONTEXT} \
  --kv int8 \
  --vision no \
  --host 0.0.0.0 \
  --port 8080 \
  --api-key "${STRATA_API_KEY}" \
  --yes

Engine arguments from strata-coder-iq1_m.json (paths omitted):

--pack <path> --native <path> --ple-gguf <path> --expert-profile <path> --expert-cache auto --spec 4
--spec-min-p 0.5 --mtp <path> --max-context 131072 --kv int8 --kv-resident 32768 --stream-experts
--vram-reserve-mib 2048 --prefill 4096

Other run-config keys: "backend": "sycl", "tool_call_recovery": true, "reasoning_close_retry": true, "fit_max_tokens": true.

What happens

The model opens the call correctly (<tool_call> + <function=NAME>), but writes the parameter tag in a different syntax. parse_tool_call only reads <parameter=NAME>, so the call reaches the client with empty arguments ({}), even though the full value is in the output. tool_call_recovery does not cover these forms.

It starts after roughly 15–25k prompt tokens and comes in streaks (2–3 broken calls in a row). It hits the Bash tool far more often than MCP tools with longer argument lists. Sampling made no difference: greedy and temperature 0.7 / top_p 0.8 / top_k 20 gave the same rate. No VRAM warnings in the log; reasoning_close_retry never fired.

Measured:

  • 2026-10-13 (v0.1.43.1): 17 of 61 Bash calls broken in one 64-turn session
  • 2026-10-14 (v0.1.44.1): 35 of 45 Bash calls broken in the first 30 min after a restart

Tool schemas

  • Bash (Continue built-in): required string command, optional timeout
  • retry_code (MCP): required strings attempt_id and feedback

Raw outputs (exact, from the server log)

  1. Name as an XML-style attribute, quoted (most common on 14.10):
<tool_call>
<function=Bash>
<parameter name="command">grep -rn "correction_fit\|correction_generate\|job_type\|correction" lotto_graph/services/lstm/correction/runner.py lotto_graph/api/routes/jobs.py 2>/dev/null | grep -v __pycache__ | sed -n '1,40p'
</parameter>
</function>
</tool_call><|im_end|>
  1. Name as an attribute, unquoted:
<tool_call>
<function=Bash>
<parameter name=command>
ls lotto_graph/worker.py 2>/dev/null; grep -rln "def.*job\|job_type\|correction" lotto_graph/worker.py 2>/dev/null
</parameter>
</function>
</tool_call><|im_end|>
  1. All arguments as JSON in a nameless <parameter> (feedback shortened here):
<tool_call>
<function=retry_code>
<parameter>
{"attempt_id": "bf3b0e1cb16b", "feedback": "Checked against the real repository file: `get_model` DOES exist on CorrectionRepository, so leave that call as it is. …"}
</parameter>
</function>
</tool_call>
  1. Not recoverable, no value at all (observed bodies of <function=Bash>):
<parameter name> command </parameter>
<parameter name> Bash </parameter>
<parameter> </parameter>
(empty body)
<|end|>
  1. Also seen, rarer:
  • <arg_value>{"command": "grep -rn …"} inside <function=Bash>
  • <function=Bash> with <parameter=dirpath> (a parameter of the List tool)
  • <parameter=previous_thinking>, <parameter=parameter>

Breakdown: on 13.10, 6 of the 17 broken calls carried the full value in a wrong syntax (forms 1–3) and 11 had none (form 4). On 14.10, 19 of 35 were forms 1–2, 3 were the <arg_value> JSON form and 13 had no value.

Local workaround for forms 1–3 (patch below)

A small patch on v0.1.44.1 (serve/frontend.py), active only with "tool_call_recovery": true and declared tools:

  • inside <function=…>…</function> it rewrites <parameter name="X">, <parameter name='X'> and <parameter name=X> to <parameter=X>;
  • it expands <parameter>{json}</parameter> into one <parameter=key> per key (non-string values as JSON);
  • a new ParamForms class does this before OutputParser sees the text, holding a tag split across stream deltas until it is complete;
  • text outside a call (reasoning, answer) is untouched.

It adds serve/test_param_forms.py: 9 tests built from the samples above, streamed in 1/3/7-character pieces and whole, inside and after the thinking, plus checks that the template form is unchanged, that the patch is off without tool_call_recovery, and that text outside a call is untouched. The existing parser tests (test_tool_name_space, test_parser_track, test_reasoning_rescue, test_reasoning_tools, test_responses) give the same results with and without it.

It does nothing for form 4, where the value is never generated; that probably needs the grammar-constrained emission proposed earlier in this issue. Happy to open a PR if this approach fits.

Patch against v0.1.44.1 (git apply)
diff --git a/serve/frontend.py b/serve/frontend.py
index c36a44d..909f364 100644
--- a/serve/frontend.py
+++ b/serve/frontend.py
@@ -870,6 +870,100 @@ def parse_tool_call(body: str, schema: dict | None = None) -> ToolCall:
 RCALL_MAX = 32768        # the most of a `<tool_call>` inside the reasoning that is held while waiting for its end (#804)
 
 
+class ParamForms:
+    """LOCAL PATCH (not upstream; see NOTATKI-ZMIANY.md next to the Strata checkout, 2026-10-14): rewrite parameter
+    tags the model writes in forms next to the template's into `<parameter=NAME>`, before OutputParser sees the
+    text.  Inside a `<function=...>` ... `</function>` only, and only with "tool_call_recovery" on:
+
+        <parameter name="NAME">  <parameter name='NAME'>  <parameter name=NAME>   -> <parameter=NAME>
+        <parameter>{"a": 1, "b": "x"}</parameter>                                 -> one <parameter=K> per key
+
+    Seen live (Qwen3.8-Flash-Next Coder IQ1_M, a coding agent with 21 tools): these calls carried the whole command
+    but came out with empty arguments, because parse_tool_call only reads `<parameter=NAME>`.  A tag split across
+    deltas is held back until it is complete, like the parser's own tags."""
+
+    NAMED = re.compile(r"""<parameter\s+name\s*=\s*(?:"([^"<>]*)"|'([^'<>]*)'|([^\s"'<>]+))\s*>""")
+    BARE = "<parameter>"
+    BARE_MAX = 65536             # the most of a nameless parameter held while waiting for its </parameter>
+
+    def __init__(self):
+        self.buf = ""
+        self.inside = False      # between a <function=...> and its </function>
+        self.rewritten = 0
+
+    def push(self, delta: str) -> str:
+        self.buf += delta
+        return self._drain(final=False)
+
+    def flush(self) -> str:
+        return self._drain(final=True)
+
+    @staticmethod
+    def _value(v) -> str:
+        return v if isinstance(v, str) else json.dumps(v, ensure_ascii=False)
+
+    def _drain(self, final: bool) -> str:
+        out = []
+        while self.buf:
+            if not self.inside:
+                i = self.buf.find(FUNC_START)
+                if i < 0:
+                    keep = 0
+                    if not final:        # the end may be the start of a `<function=`
+                        keep = next((n for n in range(min(len(FUNC_START) - 1, len(self.buf)), 0, -1)
+                                     if FUNC_START.startswith(self.buf[-n:])), 0)
+                    out.append(self.buf[:len(self.buf) - keep])
+                    self.buf = self.buf[len(self.buf) - keep:]
+                    break
+                out.append(self.buf[:i + len(FUNC_START)])
+                self.buf = self.buf[i + len(FUNC_START):]
+                self.inside = True
+                continue
+            i = self.buf.find("<")
+            if i < 0:
+                out.append(self.buf)
+                self.buf = ""
+                break
+            out.append(self.buf[:i])
+            self.buf = self.buf[i:]
+            if self.buf.startswith(FUNC_END):
+                out.append(FUNC_END)
+                self.buf = self.buf[len(FUNC_END):]
+                self.inside = False
+                continue
+            m = self.NAMED.match(self.buf)
+            if m:
+                out.append(PARAM_START + next(g for g in m.groups() if g is not None).strip() + ">")
+                self.buf = self.buf[m.end():]
+                self.rewritten += 1
+                continue
+            if self.buf.startswith(self.BARE):
+                close = self.buf.find(PARAM_END)
+                if close < 0 and not final and len(self.buf) < self.BARE_MAX:
+                    break                # wait for the whole nameless parameter
+                obj = None
+                if close >= 0:
+                    try:
+                        obj = json.loads(self.buf[len(self.BARE):close])
+                    except ValueError:
+                        obj = None
+                if isinstance(obj, dict) and obj:
+                    out.append("".join(f"<parameter={k}>\n{self._value(v)}\n</parameter>\n" for k, v in obj.items()))
+                    self.buf = self.buf[close + len(PARAM_END):].lstrip("\n")
+                    self.rewritten += 1
+                    continue
+                out.append(self.BARE)
+                self.buf = self.buf[len(self.BARE):]
+                continue
+            if not final and ">" not in self.buf and (
+                    any(t.startswith(self.buf) for t in (FUNC_END, self.BARE, "<parameter "))
+                    or self.buf.startswith("<parameter ")):
+                break                    # an unfinished tag that may still become one of the above
+            out.append("<")
+            self.buf = self.buf[1:]
+        return "".join(out)
+
+
 class OutputParser:
     """Incremental parser of the model's text. Feed deltas; get events. A tag split across deltas is held back
     until it is complete, so clients never see `<tool_` or `</thi`."""
@@ -898,6 +992,7 @@ class OutputParser:
         self.recover = recover
         self.bare = False            # the call being read opened with <function= alone (no <tool_call> around it)
         self.batch = False           # the call being finished is followed by another in the same wrapper
+        self.param_forms = ParamForms() if recover and self.schemas else None   # LOCAL PATCH, see ParamForms
         self._reset_scan()
 
     def _ok_at(self, p: int) -> bool:
@@ -1159,6 +1254,10 @@ class OutputParser:
         return best
 
     def feed(self, delta: str) -> list[Event]:
+        if self.param_forms is not None:                # LOCAL PATCH, see ParamForms
+            delta = self.param_forms.push(delta)
+            if not delta:
+                return []
         self.buf += delta
         out: list[Event] = []
         while True:
@@ -1381,6 +1480,19 @@ class OutputParser:
                     self.state, self.lead = "call", False
 
     def finish(self, reason: str | None = None) -> list[Event]:
+        """LOCAL PATCH: release what ParamForms still holds, then the original finish (below)."""
+        early = []
+        if self.param_forms is not None:
+            tail = self.param_forms.flush()
+            if self.param_forms.rewritten:
+                print(f"[strata] local patch: {self.param_forms.rewritten} parameter tag(s) rewritten to "
+                      "<parameter=NAME>", flush=True)
+            self.param_forms = None
+            if tail:
+                early = self.feed(tail)
+        return early + self._finish_unpatched(reason)
+
+    def _finish_unpatched(self, reason: str | None = None) -> list[Event]:
         """End of generation: flush whatever is held (an unterminated tool call is returned as content; one that was
         already announced stays unfinished: its JSON is not closed and no "tool_call" follows it, #211).  `reason` is
         how the turn ended: calls waiting from the reasoning become real calls only on a natural stop (None = stop);
diff --git a/serve/test_param_forms.py b/serve/test_param_forms.py
new file mode 100644
index 0000000..c6bbc27
--- /dev/null
+++ b/serve/test_param_forms.py
@@ -0,0 +1,102 @@
+"""serve/test_param_forms.py - LOCAL PATCH: parameter tags written next to the template's form keep their arguments.
+
+Seen live (Qwen3.8-Flash-Next Coder IQ1_M, a coding agent with 21 tools, "tool_call_recovery": true): the model wrote
+`<parameter name="command">`, `<parameter name=command>` or a nameless `<parameter>` holding all arguments as JSON.
+The calls carried the whole command but reached the client with empty arguments.  The samples below are the model's
+raw output from the server log (STRATA_DEBUG), shortened where marked.
+
+    python -m unittest serve.test_param_forms -v
+"""
+import sys
+import unittest
+from pathlib import Path
+
+sys.path.insert(0, str(Path(__file__).resolve().parents[1]))
+
+from serve.frontend import OutputParser  # noqa: E402
+
+TOOLS = [
+    {"name": "Bash", "parameters": {"properties": {"command": {"type": "string"},
+                                                   "timeout": {"type": "number"}}}},
+    {"name": "retry_code", "parameters": {"properties": {"attempt_id": {"type": "string"},
+                                                         "feedback": {"type": "string"}}}},
+]
+GREP = ("grep -rn \"correction_fit\\|job_type\" lotto_graph/services/lstm/correction/runner.py 2>/dev/null "
+        "| grep -v __pycache__ | sed -n '1,40p'")
+NAMED_DQ = f'<tool_call>\n<function=Bash>\n<parameter name="command">{GREP}\n</parameter>\n</function>\n</tool_call>'
+NAMED_BARE = ("<tool_call>\n<function=Bash>\n<parameter name=command>\nls lotto_graph/worker.py 2>/dev/null; "
+              "grep -rln \"job_type\" lotto_graph/worker.py\n</parameter>\n</function>\n</tool_call>")
+NAMED_SQ = "<tool_call>\n<function=Bash>\n<parameter name='command'>\nls -la\n</parameter>\n</function>\n</tool_call>"
+BARE_JSON = ('<tool_call>\n<function=retry_code>\n<parameter>\n{"attempt_id": "bf3b0e1cb16b", "feedback": '
+             '"save_backtest has NO `error_message` parameter (shortened); put it in metrics={\\"error_type\\": 1}"}'
+             '\n</parameter>\n</function>\n</tool_call>')
+CANONICAL = "<tool_call>\n<function=Bash>\n<parameter=command>\nls -la\n</parameter>\n</function>\n</tool_call>"
+
+
+def run(text, *, recover=True, stream_tools=True, step=3, thinking=True):
+    p = OutputParser(thinking=thinking, tools=TOOLS, stream_tools=stream_tools, recover=recover)
+    evs = []
+    for i in range(0, len(text), step):                # fed in small pieces, as a stream arrives
+        evs += p.feed(text[i:i + step])
+    evs += p.finish("stop")
+    return evs
+
+
+def calls(text, **kw):
+    return [(e.call.name, e.call.arguments) for e in run(text, **kw) if e.kind == "tool_call"]
+
+
+def visible(text, **kw):
+    return "".join(e.text for e in run(text, **kw) if e.kind in ("content", "reasoning") and e.text)
+
+
+class ParameterForms(unittest.TestCase):
+    def check(self, call, expected):
+        for stream_tools in (False, True):
+            for step in (1, 3, 7, 1000):
+                for lead in ("Running it.</think>\n\n", "Let me check.\n"):   # after / inside the thinking
+                    with self.subTest(stream_tools=stream_tools, step=step, lead=lead[:8]):
+                        self.assertEqual(calls(lead + call, stream_tools=stream_tools, step=step), [expected])
+
+    def test_name_in_double_quotes(self):
+        self.check(NAMED_DQ, ("Bash", {"command": GREP}))
+
+    def test_name_without_quotes(self):
+        self.check(NAMED_BARE, ("Bash", {"command": "ls lotto_graph/worker.py 2>/dev/null; "
+                                                    "grep -rln \"job_type\" lotto_graph/worker.py"}))
+
+    def test_name_in_single_quotes(self):
+        self.check(NAMED_SQ, ("Bash", {"command": "ls -la"}))
+
+    def test_nameless_parameter_holding_json(self):
+        self.check(BARE_JSON, ("retry_code", {
+            "attempt_id": "bf3b0e1cb16b",
+            "feedback": 'save_backtest has NO `error_message` parameter (shortened); put it in '
+                        'metrics={"error_type": 1}'}))
+
+    def test_the_template_form_is_unchanged(self):
+        self.check(CANONICAL, ("Bash", {"command": "ls -la"}))
+
+    def test_a_non_string_value_from_json_keeps_its_type(self):
+        call = ('<tool_call>\n<function=Bash>\n<parameter>{"command": "sleep 1", "timeout": 30}</parameter>\n'
+                '</function>\n</tool_call>')
+        self.check(call, ("Bash", {"command": "sleep 1", "timeout": 30}))
+
+
+class OnlyWhereItBelongs(unittest.TestCase):
+    def test_off_without_tool_call_recovery(self):
+        # the unpatched behaviour: the arguments are lost
+        self.assertEqual(calls("Go.</think>\n\n" + NAMED_DQ, recover=False), [("Bash", {})])
+
+    def test_text_outside_a_call_is_untouched(self):
+        text = 'The tag <parameter name="x"> and <parameter>{"a": 1}</parameter> are examples.</think>\n\nDone.'
+        self.assertEqual(visible(text), text.replace("</think>\n\n", ""))
+
+    def test_a_nameless_parameter_that_is_not_json_stays_as_written(self):
+        call = "<tool_call>\n<function=Bash>\n<parameter>\nls\n</parameter>\n</function>\n</tool_call>"
+        self.assertEqual(calls("Go.</think>\n\n" + call, recover=True),
+                         calls("Go.</think>\n\n" + call, recover=False))
+
+
+if __name__ == "__main__":
+    unittest.main()
Originally created by @mbaaku on GitHub (Oct 14, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/2451 **Hardware note:** this is an **Intel Arc Pro B60** (`bmg-g21`, SYCL backend, built with `AOT=bmg-g21`). The startup banner says the SYCL backend was tested on an Arc Pro B70 and an Arc A750, so the B60 counts as untested. I have no B70 or CUDA card to check whether the rate is backend-specific, so treat that as an open question. **Setup** - Strata v0.1.44.1 (`296b59d`), SYCL backend, 1× Intel Arc Pro B60 (24 GB), Debian Linux 13 , Docker 29.8.1 (`ONEAPI_DEVICE_SELECTOR=level_zero:0`, `STRATA_EXPERT_SPLIT=1`) - Model: Qwen3.8-Flash-Next **Coder IQ1_M** (`--kv int8`, `--max-context 131072`, 1 slot) - Run config: `"tool_call_recovery": true`, `"fit_max_tokens": true`; reasoning effort left at the model default - Client: Continue CLI (`cn`) through LiteLLM, OpenAI chat completions, streaming, **21 tools** (built-in `Bash`, `Read`, `List`, … plus MCP tools) - Raw outputs captured with `STRATA_DEBUG=1` <details> <summary>Full configuration (compose environment, .env, setup command, engine arguments, run config)</summary> `compose.yaml`, service `strata` (image built from the repo's `Dockerfile.b60`), environment: ~~~yaml environment: STRATA_DEBUG: "1" AOT: bmg-g21 REPO: ${STRATA_ROOT}/Strata BUILD_DIR: ${STRATA_ROOT}/Strata/build-sycl-aot JOBS: "28" STRATA_EXPERT_SPLIT: "1" ONEAPI_DEVICE_SELECTOR: level_zero:0 SYCL_CACHE_PERSISTENT: "0" ZES_ENABLE_SYSMAN: "1" STRATA_SYCL_ROOT: ${STRATA_ROOT} STRATA_SYCL_IMAGE: strata-sycl-b60 STRATA_VERIFY_DEVICE_PLAN: "1" STRATA_VERIFY_NO_HOST: "1" STRATA_MIRROR_MIB: "36864" ~~~ `.env` next to `compose.yaml` (`STRATA_ROOT` and `STRATA_API_KEY` omitted; the commented lines are the other quants used on the same setup): ~~~bash #STRATA_MODEL=IQ3_S #STRATA_MODEL=UD-IQ4_XS STRATA_MODEL=IQ1_M #STRATA_FAMILY=qwen #STRATA_FAMILY=unsloth STRATA_FAMILY=coder STRATA_CONTEXT=131072 ~~~ Container command (after an incremental SYCL build when the checked-out commit changed): ~~~bash exec ./setup.sh \ --backend sycl \ --family ${STRATA_FAMILY} \ --model ${STRATA_MODEL} \ --gguf-dir "${STRATA_ROOT}/models/${STRATA_MODEL}" \ --models-dir "${STRATA_ROOT}/models" \ --data-dir "${STRATA_ROOT}/data" \ --context ${STRATA_CONTEXT} \ --kv int8 \ --vision no \ --host 0.0.0.0 \ --port 8080 \ --api-key "${STRATA_API_KEY}" \ --yes ~~~ Engine arguments from `strata-coder-iq1_m.json` (paths omitted): ~~~text --pack <path> --native <path> --ple-gguf <path> --expert-profile <path> --expert-cache auto --spec 4 --spec-min-p 0.5 --mtp <path> --max-context 131072 --kv int8 --kv-resident 32768 --stream-experts --vram-reserve-mib 2048 --prefill 4096 ~~~ Other run-config keys: `"backend": "sycl"`, `"tool_call_recovery": true`, `"reasoning_close_retry": true`, `"fit_max_tokens": true`. </details> **What happens** The model opens the call correctly (`<tool_call>` + `<function=NAME>`), but writes the parameter tag in a different syntax. `parse_tool_call` only reads `<parameter=NAME>`, so the call reaches the client with **empty arguments** (`{}`), even though the full value is in the output. `tool_call_recovery` does not cover these forms. It starts after roughly 15–25k prompt tokens and comes in streaks (2–3 broken calls in a row). It hits the `Bash` tool far more often than MCP tools with longer argument lists. Sampling made no difference: greedy and temperature 0.7 / top_p 0.8 / top_k 20 gave the same rate. No VRAM warnings in the log; `reasoning_close_retry` never fired. Measured: - 2026-10-13 (v0.1.43.1): 17 of 61 `Bash` calls broken in one 64-turn session - 2026-10-14 (v0.1.44.1): 35 of 45 `Bash` calls broken in the first 30 min after a restart **Tool schemas** - `Bash` (Continue built-in): required string `command`, optional `timeout` - `retry_code` (MCP): required strings `attempt_id` and `feedback` **Raw outputs (exact, from the server log)** 1. Name as an XML-style attribute, quoted (most common on 14.10): ~~~text <tool_call> <function=Bash> <parameter name="command">grep -rn "correction_fit\|correction_generate\|job_type\|correction" lotto_graph/services/lstm/correction/runner.py lotto_graph/api/routes/jobs.py 2>/dev/null | grep -v __pycache__ | sed -n '1,40p' </parameter> </function> </tool_call><|im_end|> ~~~ 2. Name as an attribute, unquoted: ~~~text <tool_call> <function=Bash> <parameter name=command> ls lotto_graph/worker.py 2>/dev/null; grep -rln "def.*job\|job_type\|correction" lotto_graph/worker.py 2>/dev/null </parameter> </function> </tool_call><|im_end|> ~~~ 3. All arguments as JSON in a nameless `<parameter>` (feedback shortened here): ~~~text <tool_call> <function=retry_code> <parameter> {"attempt_id": "bf3b0e1cb16b", "feedback": "Checked against the real repository file: `get_model` DOES exist on CorrectionRepository, so leave that call as it is. …"} </parameter> </function> </tool_call> ~~~ 4. Not recoverable, no value at all (observed bodies of `<function=Bash>`): ~~~text <parameter name> command </parameter> <parameter name> Bash </parameter> <parameter> </parameter> (empty body) <|end|> ~~~ 5. Also seen, rarer: - `<arg_value>{"command": "grep -rn …"}` inside `<function=Bash>` - `<function=Bash>` with `<parameter=dirpath>` (a parameter of the `List` tool) - `<parameter=previous_thinking>`, `<parameter=parameter>` Breakdown: on 13.10, 6 of the 17 broken calls carried the full value in a wrong syntax (forms 1–3) and 11 had none (form 4). On 14.10, 19 of 35 were forms 1–2, 3 were the `<arg_value>` JSON form and 13 had no value. **Local workaround for forms 1–3 (patch below)** A small patch on v0.1.44.1 (`serve/frontend.py`), active only with `"tool_call_recovery": true` and declared tools: - inside `<function=…>…</function>` it rewrites `<parameter name="X">`, `<parameter name='X'>` and `<parameter name=X>` to `<parameter=X>`; - it expands `<parameter>{json}</parameter>` into one `<parameter=key>` per key (non-string values as JSON); - a new `ParamForms` class does this before `OutputParser` sees the text, holding a tag split across stream deltas until it is complete; - text outside a call (reasoning, answer) is untouched. It adds `serve/test_param_forms.py`: 9 tests built from the samples above, streamed in 1/3/7-character pieces and whole, inside and after the thinking, plus checks that the template form is unchanged, that the patch is off without `tool_call_recovery`, and that text outside a call is untouched. The existing parser tests (`test_tool_name_space`, `test_parser_track`, `test_reasoning_rescue`, `test_reasoning_tools`, `test_responses`) give the same results with and without it. It does nothing for form 4, where the value is never generated; that probably needs the grammar-constrained emission proposed earlier in this issue. Happy to open a PR if this approach fits. <details> <summary>Patch against v0.1.44.1 (<code>git apply</code>)</summary> ~~~diff diff --git a/serve/frontend.py b/serve/frontend.py index c36a44d..909f364 100644 --- a/serve/frontend.py +++ b/serve/frontend.py @@ -870,6 +870,100 @@ def parse_tool_call(body: str, schema: dict | None = None) -> ToolCall: RCALL_MAX = 32768 # the most of a `<tool_call>` inside the reasoning that is held while waiting for its end (#804) +class ParamForms: + """LOCAL PATCH (not upstream; see NOTATKI-ZMIANY.md next to the Strata checkout, 2026-10-14): rewrite parameter + tags the model writes in forms next to the template's into `<parameter=NAME>`, before OutputParser sees the + text. Inside a `<function=...>` ... `</function>` only, and only with "tool_call_recovery" on: + + <parameter name="NAME"> <parameter name='NAME'> <parameter name=NAME> -> <parameter=NAME> + <parameter>{"a": 1, "b": "x"}</parameter> -> one <parameter=K> per key + + Seen live (Qwen3.8-Flash-Next Coder IQ1_M, a coding agent with 21 tools): these calls carried the whole command + but came out with empty arguments, because parse_tool_call only reads `<parameter=NAME>`. A tag split across + deltas is held back until it is complete, like the parser's own tags.""" + + NAMED = re.compile(r"""<parameter\s+name\s*=\s*(?:"([^"<>]*)"|'([^'<>]*)'|([^\s"'<>]+))\s*>""") + BARE = "<parameter>" + BARE_MAX = 65536 # the most of a nameless parameter held while waiting for its </parameter> + + def __init__(self): + self.buf = "" + self.inside = False # between a <function=...> and its </function> + self.rewritten = 0 + + def push(self, delta: str) -> str: + self.buf += delta + return self._drain(final=False) + + def flush(self) -> str: + return self._drain(final=True) + + @staticmethod + def _value(v) -> str: + return v if isinstance(v, str) else json.dumps(v, ensure_ascii=False) + + def _drain(self, final: bool) -> str: + out = [] + while self.buf: + if not self.inside: + i = self.buf.find(FUNC_START) + if i < 0: + keep = 0 + if not final: # the end may be the start of a `<function=` + keep = next((n for n in range(min(len(FUNC_START) - 1, len(self.buf)), 0, -1) + if FUNC_START.startswith(self.buf[-n:])), 0) + out.append(self.buf[:len(self.buf) - keep]) + self.buf = self.buf[len(self.buf) - keep:] + break + out.append(self.buf[:i + len(FUNC_START)]) + self.buf = self.buf[i + len(FUNC_START):] + self.inside = True + continue + i = self.buf.find("<") + if i < 0: + out.append(self.buf) + self.buf = "" + break + out.append(self.buf[:i]) + self.buf = self.buf[i:] + if self.buf.startswith(FUNC_END): + out.append(FUNC_END) + self.buf = self.buf[len(FUNC_END):] + self.inside = False + continue + m = self.NAMED.match(self.buf) + if m: + out.append(PARAM_START + next(g for g in m.groups() if g is not None).strip() + ">") + self.buf = self.buf[m.end():] + self.rewritten += 1 + continue + if self.buf.startswith(self.BARE): + close = self.buf.find(PARAM_END) + if close < 0 and not final and len(self.buf) < self.BARE_MAX: + break # wait for the whole nameless parameter + obj = None + if close >= 0: + try: + obj = json.loads(self.buf[len(self.BARE):close]) + except ValueError: + obj = None + if isinstance(obj, dict) and obj: + out.append("".join(f"<parameter={k}>\n{self._value(v)}\n</parameter>\n" for k, v in obj.items())) + self.buf = self.buf[close + len(PARAM_END):].lstrip("\n") + self.rewritten += 1 + continue + out.append(self.BARE) + self.buf = self.buf[len(self.BARE):] + continue + if not final and ">" not in self.buf and ( + any(t.startswith(self.buf) for t in (FUNC_END, self.BARE, "<parameter ")) + or self.buf.startswith("<parameter ")): + break # an unfinished tag that may still become one of the above + out.append("<") + self.buf = self.buf[1:] + return "".join(out) + + class OutputParser: """Incremental parser of the model's text. Feed deltas; get events. A tag split across deltas is held back until it is complete, so clients never see `<tool_` or `</thi`.""" @@ -898,6 +992,7 @@ class OutputParser: self.recover = recover self.bare = False # the call being read opened with <function= alone (no <tool_call> around it) self.batch = False # the call being finished is followed by another in the same wrapper + self.param_forms = ParamForms() if recover and self.schemas else None # LOCAL PATCH, see ParamForms self._reset_scan() def _ok_at(self, p: int) -> bool: @@ -1159,6 +1254,10 @@ class OutputParser: return best def feed(self, delta: str) -> list[Event]: + if self.param_forms is not None: # LOCAL PATCH, see ParamForms + delta = self.param_forms.push(delta) + if not delta: + return [] self.buf += delta out: list[Event] = [] while True: @@ -1381,6 +1480,19 @@ class OutputParser: self.state, self.lead = "call", False def finish(self, reason: str | None = None) -> list[Event]: + """LOCAL PATCH: release what ParamForms still holds, then the original finish (below).""" + early = [] + if self.param_forms is not None: + tail = self.param_forms.flush() + if self.param_forms.rewritten: + print(f"[strata] local patch: {self.param_forms.rewritten} parameter tag(s) rewritten to " + "<parameter=NAME>", flush=True) + self.param_forms = None + if tail: + early = self.feed(tail) + return early + self._finish_unpatched(reason) + + def _finish_unpatched(self, reason: str | None = None) -> list[Event]: """End of generation: flush whatever is held (an unterminated tool call is returned as content; one that was already announced stays unfinished: its JSON is not closed and no "tool_call" follows it, #211). `reason` is how the turn ended: calls waiting from the reasoning become real calls only on a natural stop (None = stop); diff --git a/serve/test_param_forms.py b/serve/test_param_forms.py new file mode 100644 index 0000000..c6bbc27 --- /dev/null +++ b/serve/test_param_forms.py @@ -0,0 +1,102 @@ +"""serve/test_param_forms.py - LOCAL PATCH: parameter tags written next to the template's form keep their arguments. + +Seen live (Qwen3.8-Flash-Next Coder IQ1_M, a coding agent with 21 tools, "tool_call_recovery": true): the model wrote +`<parameter name="command">`, `<parameter name=command>` or a nameless `<parameter>` holding all arguments as JSON. +The calls carried the whole command but reached the client with empty arguments. The samples below are the model's +raw output from the server log (STRATA_DEBUG), shortened where marked. + + python -m unittest serve.test_param_forms -v +""" +import sys +import unittest +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parents[1])) + +from serve.frontend import OutputParser # noqa: E402 + +TOOLS = [ + {"name": "Bash", "parameters": {"properties": {"command": {"type": "string"}, + "timeout": {"type": "number"}}}}, + {"name": "retry_code", "parameters": {"properties": {"attempt_id": {"type": "string"}, + "feedback": {"type": "string"}}}}, +] +GREP = ("grep -rn \"correction_fit\\|job_type\" lotto_graph/services/lstm/correction/runner.py 2>/dev/null " + "| grep -v __pycache__ | sed -n '1,40p'") +NAMED_DQ = f'<tool_call>\n<function=Bash>\n<parameter name="command">{GREP}\n</parameter>\n</function>\n</tool_call>' +NAMED_BARE = ("<tool_call>\n<function=Bash>\n<parameter name=command>\nls lotto_graph/worker.py 2>/dev/null; " + "grep -rln \"job_type\" lotto_graph/worker.py\n</parameter>\n</function>\n</tool_call>") +NAMED_SQ = "<tool_call>\n<function=Bash>\n<parameter name='command'>\nls -la\n</parameter>\n</function>\n</tool_call>" +BARE_JSON = ('<tool_call>\n<function=retry_code>\n<parameter>\n{"attempt_id": "bf3b0e1cb16b", "feedback": ' + '"save_backtest has NO `error_message` parameter (shortened); put it in metrics={\\"error_type\\": 1}"}' + '\n</parameter>\n</function>\n</tool_call>') +CANONICAL = "<tool_call>\n<function=Bash>\n<parameter=command>\nls -la\n</parameter>\n</function>\n</tool_call>" + + +def run(text, *, recover=True, stream_tools=True, step=3, thinking=True): + p = OutputParser(thinking=thinking, tools=TOOLS, stream_tools=stream_tools, recover=recover) + evs = [] + for i in range(0, len(text), step): # fed in small pieces, as a stream arrives + evs += p.feed(text[i:i + step]) + evs += p.finish("stop") + return evs + + +def calls(text, **kw): + return [(e.call.name, e.call.arguments) for e in run(text, **kw) if e.kind == "tool_call"] + + +def visible(text, **kw): + return "".join(e.text for e in run(text, **kw) if e.kind in ("content", "reasoning") and e.text) + + +class ParameterForms(unittest.TestCase): + def check(self, call, expected): + for stream_tools in (False, True): + for step in (1, 3, 7, 1000): + for lead in ("Running it.</think>\n\n", "Let me check.\n"): # after / inside the thinking + with self.subTest(stream_tools=stream_tools, step=step, lead=lead[:8]): + self.assertEqual(calls(lead + call, stream_tools=stream_tools, step=step), [expected]) + + def test_name_in_double_quotes(self): + self.check(NAMED_DQ, ("Bash", {"command": GREP})) + + def test_name_without_quotes(self): + self.check(NAMED_BARE, ("Bash", {"command": "ls lotto_graph/worker.py 2>/dev/null; " + "grep -rln \"job_type\" lotto_graph/worker.py"})) + + def test_name_in_single_quotes(self): + self.check(NAMED_SQ, ("Bash", {"command": "ls -la"})) + + def test_nameless_parameter_holding_json(self): + self.check(BARE_JSON, ("retry_code", { + "attempt_id": "bf3b0e1cb16b", + "feedback": 'save_backtest has NO `error_message` parameter (shortened); put it in ' + 'metrics={"error_type": 1}'})) + + def test_the_template_form_is_unchanged(self): + self.check(CANONICAL, ("Bash", {"command": "ls -la"})) + + def test_a_non_string_value_from_json_keeps_its_type(self): + call = ('<tool_call>\n<function=Bash>\n<parameter>{"command": "sleep 1", "timeout": 30}</parameter>\n' + '</function>\n</tool_call>') + self.check(call, ("Bash", {"command": "sleep 1", "timeout": 30})) + + +class OnlyWhereItBelongs(unittest.TestCase): + def test_off_without_tool_call_recovery(self): + # the unpatched behaviour: the arguments are lost + self.assertEqual(calls("Go.</think>\n\n" + NAMED_DQ, recover=False), [("Bash", {})]) + + def test_text_outside_a_call_is_untouched(self): + text = 'The tag <parameter name="x"> and <parameter>{"a": 1}</parameter> are examples.</think>\n\nDone.' + self.assertEqual(visible(text), text.replace("</think>\n\n", "")) + + def test_a_nameless_parameter_that_is_not_json_stays_as_written(self): + call = "<tool_call>\n<function=Bash>\n<parameter>\nls\n</parameter>\n</function>\n</tool_call>" + self.assertEqual(calls("Go.</think>\n\n" + call, recover=True), + calls("Go.</think>\n\n" + call, recover=False)) + + +if __name__ == "__main__": + unittest.main() ~~~ </details>
Author
Owner

@mbaaku commented on GitHub (Oct 17, 2026):

Another recoverable form: all arguments as JSON under a parameter named arguments

Same setup (Qwen3.8-Flash-Next Coder IQ1_M, SYCL, Arc Pro B60, "tool_call_recovery": true), now on v0.1.44.1 and seen again after a checkout of 0.1.45. The model wrapped the whole argument object in one parameter called arguments:

<tool_call>
<function=Bash>
<parameter=arguments>
{"command": "sed -n '/^## Contents/,/^## Decisions/p' ../docs/SPEC.md"}
</parameter>
</function>
</tool_call>

Bash declares no arguments parameter, so the call reached the client as {"arguments": {...}} with the required command missing. Once it started, the model repeated this form 108 times in a row within a few minutes, at only ~31–33k prompt tokens (each failed call stays in the history and gets imitated).

Suggested handling under tool_call_recovery, next to the nameless <parameter>{json}</parameter> case from #2572: when a <parameter=X> value parses as a JSON object, X is one of arguments, args, parameters, params, input, kwargs, and the tool does not declare a parameter named X, read the object's keys as the parameters. A tool that really has an arguments parameter keeps it unchanged.

We run this locally on top of the forms from #2572; two tests cover it: the wrapped form streamed in 1/3/7-character pieces and whole gives Bash {"command": ...}, and a tool declaring its own string arguments gets the text untouched.

<!-- gh-comment-id:6231385534 --> @mbaaku commented on GitHub (Oct 17, 2026): ### Another recoverable form: all arguments as JSON under a parameter named `arguments` Same setup (Qwen3.8-Flash-Next Coder IQ1_M, SYCL, Arc Pro B60, `"tool_call_recovery": true`), now on v0.1.44.1 and seen again after a checkout of 0.1.45. The model wrapped the whole argument object in one parameter called `arguments`: ~~~text <tool_call> <function=Bash> <parameter=arguments> {"command": "sed -n '/^## Contents/,/^## Decisions/p' ../docs/SPEC.md"} </parameter> </function> </tool_call> ~~~ `Bash` declares no `arguments` parameter, so the call reached the client as `{"arguments": {...}}` with the required `command` missing. Once it started, the model repeated this form 108 times in a row within a few minutes, at only ~31–33k prompt tokens (each failed call stays in the history and gets imitated). Suggested handling under `tool_call_recovery`, next to the nameless `<parameter>{json}</parameter>` case from #2572: when a `<parameter=X>` value parses as a JSON object, X is one of `arguments`, `args`, `parameters`, `params`, `input`, `kwargs`, and the tool does **not** declare a parameter named X, read the object's keys as the parameters. A tool that really has an `arguments` parameter keeps it unchanged. We run this locally on top of the forms from #2572; two tests cover it: the wrapped form streamed in 1/3/7-character pieces and whole gives `Bash {"command": ...}`, and a tool declaring its own string `arguments` gets the text untouched.
Author
Owner

@Niko1221 commented on GitHub (Oct 19, 2026):

Thanks for taking the time to report this.

We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected.

To reopen it takes about two minutes:

  1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see.
  2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other].
  3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system.
  4. Comment /reopen. A check runs and either reopens the issue or lists what is still missing.

The rules are in CONTRIBUTING.md.

<!-- gh-comment-id:6271057169 --> @Niko1221 commented on GitHub (Oct 19, 2026): Thanks for taking the time to report this. We're resetting the tracker for 0.2.0-beta. There are more than 1,300 open issues and pull requests, too many for us to read properly, so we're closing everything that isn't being worked on right now. Closed here does not mean rejected. To reopen it takes about two minutes: 1. Re-test on 0.2.0-beta. It may already be fixed. Write down what you see. 2. Start the title with its area: [Engine], [GUI], [TUI], [Benchmark], [Docs] or [Other]. 3. Fill in the parts of the issue form: what happened, the Strata version, your graphics card, memory and system. 4. Comment `/reopen`. A check runs and either reopens the issue or lists what is still missing. The rules are in [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md).
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#996
No description provided.