[GH-ISSUE #4078] [Engine] Tool-call markup inside a parameter value is cut silently: the tool runs with truncated arguments #1774

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

Originally created by @ackalker on GitHub (Oct 25, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4078

Area

[Engine] (speed, kernels, models, the server and API)

Engine (serve/), run from source: serve/server.py started as
python serve/server.py --engine strata --config strata-iq3_s.json.

Desktop app, Terminal or source?

Source (START-HERE.bat, setup.sh or a build)

Reproduction status

Reproduced locally - deterministic at parser level, no model, no GPU and no
network needed (the script feeds serve.frontend.OutputParser in 7-character deltas, like a real
server feed). It is not replayed end to end against a live server in this report.

What happened

When a model puts tool-call markup inside a tool argument - which is ordinary content for an agent
that edits a chat template, writes a parser test fixture, or quotes an earlier turn of its own
transcript - the call is still delivered, but its arguments are cut. There is no error, no
unread count and no log line, so the client runs the tool with the shortened value and reports
success. A write or edit call can therefore save a truncated file with nothing left to trace.

Two shapes, both observed against serve/frontend.py:

  1. One parameter, nested markup inside its value. The value ends where the nested closing tag
    appears (the closing tag is grammar-valid there, param_end / call_end,
    serve/frontend.py:712 and :727), and everything the model still intended is emitted as
    ordinary assistant content afterwards. The delivered tool_call carries the head of the value
    only. parser.unread stays 0; parser.unread_names stays empty.
  2. The same parameter written again after the nested block. The parser delivers only the last
    value: the head of the argument is dropped completely, again with unread == 0.

In the real case that triggered this report the argument was a shell heredoc
(python3 - <<'PY' … PY) whose body contained a quoted tool-call block; the delivered command was
cut in the middle of the heredoc and the remainder came back as the answer text.

tool_call_recovery: true does not change either shape (case 4b of the attached script).

Expected

A nested opener or closer that appears inside a parameter value should be text, the way #210 made
the closing-tag case behave via param_end / call_end ("a value may contain either tag",
serve/frontend.py:729); the opener rules that currently decide are _ok_at / _opener_ok
(serve/frontend.py:957, :1084, the #1058 fence rules at :1396-1397).

If keeping the current termination is deliberate, then at minimum count it: an unread-style
counter plus the [strata] … line the server already prints for the #3441 case
(serve/server.py:5599-5603), so "my tool ran on half the text" is diagnosable at all. There is no
escaping anywhere in serve/chat_template.jinja (grep -c escape returns 0), so today there is no
way for a client to pass file content containing that markup through a parameter at all.

Smallest steps or command that reproduce it

repro.py (attached below) runs every case against a checkout; from the repository root:

python3 repro.py --repo .

Cases 4 and 4b are this problem. The script prints, for each case, the delivered calls with their
arguments, the answer text, the reasoning text, and unread / rescued / refused. In the script
the markup strings are built at runtime from chr(60) / chr(62); they are never written literally
in the file, so reading the script cannot inject markup into anyone's session or editor buffer.

Case 4 (one parameter with a nested block in its value): the call is delivered as
bash with command cut after the nested closing tag, the rest of the model's text comes back as
content, and the counters read unread=0 rescued=0 refused=0.
Case 4b is the same input with recover=True: identical output.

In prose (the tags are written as «tool_call», «/parameter» and so on here; repro.py prints
the real strings): the intended command was

python3 - <<'PY'
text = '«tool_call» «function=read» «parameter=path» /tmp/x «/parameter» «/function» «/tool_call»'
more lines that must not be lost

and what the client receives is a bash call whose command stops at the nested «/parameter».

Strata version

v0.2.4.2-6-g7dd5cf18 (source checkout, git describe), engine 0.1.49.1.

Re-verified against main as fetched on 2026-10-25 (fa663fab, 136 commits newer): git diff 7dd5cf18 fa663fab -- serve/ is empty, i.e. nothing under serve/ changed in between, and the
script reproduces identically there.

Graphics card, memory and system

RTX 5080 16 GB · 60 GB RAM · Linux (CachyOS, kernel 7.3.0-5), Python 3.13. The reproduction itself
needs no GPU, no model file and no server.

Model, size and settings

Where it was first seen: Qwen3.8-Flash-Next GGUF, IQ3_S and IQ3_XXS, 131072 context, reached through
llama-swap from an agent client (Pi) with tool_call_recovery on.

Logs

Nothing at all is logged for this case, which is part of the report. Compare #3441's path: when a
call block is returned as text, serve/server.py:5599-5603 prints a [strata] … line with the
names involved. Here the block is read as a call, so no counter moves and the server says nothing.

  • #210 (closed) fixed termination on the closing tags; this is the same symptom class reached from
    the nested-opener side, and it survives that fix.
  • #1058 (closed) covers openers quoted in prose (fences and inline code) - this value is inside a
    call already, so the fence rule does not apply.
  • #2037 (closed) is about fenced JSON inside a wrapper, not about values.
  • #3441 / #3075 are about calls that are returned as text; there the tool never runs. Here the tool
    runs with cut arguments, which is the dangerous difference.

Attached: repro.py (self-contained; the markup strings are built at runtime, never literal in the file)

#!/usr/bin/env python3
"""Deterministic parser-level repro of three Strata `serve` defects seen through llama-swap + Pi.

Run:  python3 repro.py [--repo /path/to/Strata] [--old]
      (--old also runs case A against the parser as of 2026-10-20, i.e. before 70f42407.)

This file never contains the markup tags literally: they are built from chr(60)/chr(62) at
runtime. Keep it that way - a session whose context contains them verbatim can corrupt itself
(see README.md, "Why this file is written like this").
"""
import argparse
import importlib.util
import os
import subprocess
import sys

T, G = chr(60), chr(62)
THINK_OPEN, THINK_CLOSE = f"{T}think{G}", f"{T}/think{G}"
CALL_OPEN, CALL_CLOSE = f"{T}tool_call{G}", f"{T}/tool_call{G}"
PARAM_CLOSE, FUNC_CLOSE = f"{T}/parameter{G}", f"{T}/function{G}"


def func(name):
    return f"{T}function={name}{G}"


def param(name):
    return f"{T}parameter={name}{G}"


# flat (Responses spelling): OutputParser.__init__ does {t.get("name"): t for t in tools}
TOOLS = [
    {"name": "bash", "parameters": {"type": "object",
     "properties": {"command": {"type": "string"}}, "required": ["command"]}},
    {"name": "read", "parameters": {"type": "object",
     "properties": {"path": {"type": "string"}}}},
]


def load_parser(repo, old=False):
    """Return (label, OutputParser, needs_extra_kwargs) for the current or the pre-70f42407 parser."""
    sys.path.insert(0, repo)
    if not old:
        from serve.frontend import OutputParser
        return "current HEAD", OutputParser
    src = subprocess.run(["git", "-C", repo, "show", "70f42407^:serve/frontend.py"],
                         capture_output=True, text=True, check=True).stdout
    path = "/tmp/strata_frontend_pre_70f42407.py"
    open(path, "w").write(src)
    spec = importlib.util.spec_from_file_location("strata_frontend_old", path)
    mod = importlib.util.module_from_spec(spec)
    sys.modules["strata_frontend_old"] = mod          # dataclass needs the module registered
    spec.loader.exec_module(mod)
    return "70f42407^ (2026-10-20)", mod.OutputParser


def run(cls, text, tools=TOOLS, declared_only=True, recover=False, chunk=7):
    kw = {}
    try:                                   # pre-70f42407 has no declared_only / recover
        p = cls(thinking=True, tools=tools, stream_tools=False,
                recover=recover, declared_only=declared_only)
    except TypeError:
        p = cls(thinking=True, tools=tools, stream_tools=False)
    evs = []
    for i in range(0, len(text), chunk):   # stream in small deltas, like a real server feed
        evs += p.feed(text[i:i + chunk])
    evs += p.finish("stop")
    return evs, p


def show(title, evs, p, expect, bug=False):
    """expect(calls, content_text, reasoning_text, parser) -> True when the case behaved as claimed.
    bug=True means the claimed behaviour is the defect, so True prints REPRODUCED."""
    calls = [e.call for e in evs if e.kind == "tool_call"]
    text = "".join(e.text for e in evs if e.kind == "content")
    reasoning = "".join(e.text for e in evs if e.kind == "reasoning")
    ok = expect(calls, text, reasoning, p)
    if bug:
        verdict = "REPRODUCED" if ok else "*** DID NOT REPRODUCE ***"
    else:
        verdict = "as intended" if ok else "*** REGRESSION / CHANGED BEHAVIOUR ***"
    print(f"\n=== {title}\n    {verdict}")
    print(f"    reasoning: {reasoning[:70]!r}")
    print(f"    content  : {text[:160]!r}")
    print(f"    calls    : {[(c.name, c.arguments) for c in calls]}")
    print(f"    unread   : {getattr(p, 'unread', 'n/a (pre-70f42407)')} "
          f"{getattr(p, 'unread_names', '')}  rescued={p.rescued} refused={p.refused}")


def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--repo", default=os.environ.get("STRATA", os.path.expanduser("~/pg/Strata")))
    ap.add_argument("--old", action="store_true", help="also compare against the pre-70f42407 parser")
    a = ap.parse_args()

    label, cls = load_parser(a.repo)
    print(f"Strata repo: {a.repo}   parser: {label}")

    # 0. sanity: a clean, well-formed, declared call parses
    clean = (f"{THINK_OPEN}\nLet me run it.\n{THINK_CLOSE}\n\n"
             f"{CALL_OPEN}\n{func('bash')}\n{param('command')}\nls\n{PARAM_CLOSE}\n{FUNC_CLOSE}\n{CALL_CLOSE}")
    evs, p = run(cls, clean)
    show("0. sanity - clean declared call (must parse as a call)", evs, p,
         lambda c, t, r, p: len(c) == 1 and c[0].name == "bash" and c[0].arguments == {"command": "ls"})

    # 1. CONTROL: a think-close quoted with backticks inside the thinking stays reasoning text (#537)
    quoted = (f"{THINK_OPEN}\nI wrote `{THINK_CLOSE}` inside my reasoning\n"
              f"and kept thinking here\n{THINK_CLOSE}\n\nall done")
    evs, p = run(cls, quoted)
    show("1. control - quoted think-close in thinking (#537 protects this)", evs, p,
         lambda c, t, r, p: "kept thinking" in r and "kept thinking" not in t)

    # 2. DEFECT B: the same tag at line start ends the reasoning block; the rest leaks as content
    leak = (f"{THINK_OPEN}\nfirst part of the reasoning\n{THINK_CLOSE}\n"
            f"second part of the reasoning leaks into the answer\n{THINK_CLOSE}\n\nthe answer")
    evs, p = run(cls, leak)
    show("2. DEFECT B - bare think-close mid-thinking leaks the rest as visible content", evs, p,
         lambda c, t, r, p: "leaks into the answer" in t, bug=True)

    # 3. DEFECT A: a well-formed call for a tool the request did not declare comes back as text
    undeclared = (f"{THINK_OPEN}\nplan\n{THINK_CLOSE}\n\n{CALL_OPEN}\n{func('AskUserQuestion')}\n"
                  f"{param('questions')}\n[]{PARAM_CLOSE}\n{FUNC_CLOSE}\n{CALL_CLOSE}")
    evs, p = run(cls, undeclared)
    show("3. DEFECT A - call for an undeclared name returns as text, loop cannot continue", evs, p,
         lambda c, t, r, p: not c and "AskUserQuestion" in t and p.unread == 1, bug=True)

    # 4. DEFECT C: literal call markup inside a parameter value truncates the call silently
    inner = (f"python3 - <<'EOF'\ntext = '''{CALL_OPEN}\n{func('read')}\n"
             f"{param('path')}\n/tmp/x\n{PARAM_CLOSE}")
    trunc = (f"{THINK_OPEN}\nplan\n{THINK_CLOSE}\n\n{CALL_OPEN}\n{func('bash')}\n{param('command')}\n"
             f"{inner}\n{PARAM_CLOSE}\n{FUNC_CLOSE}\n{CALL_CLOSE}\nok")
    evs, p = run(cls, trunc)
    show("4. DEFECT C - markup in an argument value truncates args silently (unread stays 0)", evs, p,
         lambda c, t, r, p: len(c) == 1 and "EOF" in str(c[0].arguments)
         and not str(c[0].arguments).endswith("EOF'\n") and p.unread == 0, bug=True)

    evs, p = run(cls, trunc, recover=True)
    show("4b. DEFECT C with tool_call_recovery=True (does NOT help)", evs, p,
         lambda c, t, r, p: len(c) == 1 and p.unread == 0, bug=True)

    # 5. Not a defect, but the answer to "is replayed thinking the cause?": think-tags in a replayed
    #    assistant message ARE masked by mark_think_literals; tool-call literals deliberately are not.
    from serve.frontend import mark_think_literals, literal_tags
    def ctrl(name):                       # control tokens are never spelled literally either
        return chr(60) + chr(124) + name + chr(124) + chr(62)
    tags = literal_tags((ctrl("im_start"), ctrl("im_end")))
    msgs = [{"role": "assistant", "content": "answer",
             "reasoning_content": f"I wrote\n{THINK_CLOSE}\nand also {CALL_OPEN} bare in my thinking"}]
    out, _, changed = mark_think_literals(msgs, None, tags)
    rc = out[0]["reasoning_content"]
    print("\n=== 5. input side: mark_think_literals on a replayed assistant message")
    print(f"    changed: {changed}")
    print(f"    think-close masked in reasoning_content : {THINK_CLOSE not in rc}")
    print(f"    tool_call-open masked in assistant msg  : {CALL_OPEN not in rc}"
          "   <- False is intentional (frontend.py:366)")

    if a.old:
        olabel, ocls = load_parser(a.repo, old=True)
        evs, p = run(ocls, undeclared)
        show(f"6. DEFECT A on parser {olabel} - same input, different behaviour", evs, p,
             lambda c, t, r, p: len(c) == 1 and c[0].name == "AskUserQuestion", bug=True)


if __name__ == "__main__":
    main()
Originally created by @ackalker on GitHub (Oct 25, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4078 ### Area [Engine] (speed, kernels, models, the server and API) Engine (`serve/`), run from source: `serve/server.py` started as `python serve/server.py --engine strata --config strata-iq3_s.json`. ### Desktop app, Terminal or source? Source (START-HERE.bat, setup.sh or a build) ### Reproduction status Reproduced locally - deterministic at parser level, no model, no GPU and no network needed (the script feeds `serve.frontend.OutputParser` in 7-character deltas, like a real server feed). It is *not* replayed end to end against a live server in this report. ### What happened When a model puts tool-call markup inside a tool argument - which is ordinary content for an agent that edits a chat template, writes a parser test fixture, or quotes an earlier turn of its own transcript - the call is still delivered, but its arguments are cut. There is no error, no `unread` count and no log line, so the client runs the tool with the shortened value and reports success. A `write` or `edit` call can therefore save a truncated file with nothing left to trace. Two shapes, both observed against `serve/frontend.py`: 1. **One parameter, nested markup inside its value.** The value ends where the nested closing tag appears (the closing tag is grammar-valid there, `param_end` / `call_end`, `serve/frontend.py:712` and `:727`), and everything the model still intended is emitted as ordinary assistant content afterwards. The delivered `tool_call` carries the head of the value only. `parser.unread` stays `0`; `parser.unread_names` stays empty. 2. **The same parameter written again after the nested block.** The parser delivers only the last value: the head of the argument is dropped completely, again with `unread == 0`. In the real case that triggered this report the argument was a shell heredoc (`python3 - <<'PY' … PY`) whose body contained a quoted tool-call block; the delivered command was cut in the middle of the heredoc and the remainder came back as the answer text. `tool_call_recovery: true` does not change either shape (case 4b of the attached script). ### Expected A nested opener or closer that appears inside a parameter value should be text, the way #210 made the closing-tag case behave via `param_end` / `call_end` ("a value may contain either tag", `serve/frontend.py:729`); the opener rules that currently decide are `_ok_at` / `_opener_ok` (`serve/frontend.py:957`, `:1084`, the #1058 fence rules at `:1396-1397`). If keeping the current termination is deliberate, then at minimum count it: an `unread`-style counter plus the `[strata] …` line the server already prints for the #3441 case (`serve/server.py:5599-5603`), so "my tool ran on half the text" is diagnosable at all. There is no escaping anywhere in `serve/chat_template.jinja` (`grep -c escape` returns 0), so today there is no way for a client to pass file content containing that markup through a parameter at all. ### Smallest steps or command that reproduce it `repro.py` (attached below) runs every case against a checkout; from the repository root: ```sh python3 repro.py --repo . ``` Cases 4 and 4b are this problem. The script prints, for each case, the delivered calls with their arguments, the answer text, the reasoning text, and `unread` / `rescued` / `refused`. In the script the markup strings are built at runtime from `chr(60)` / `chr(62)`; they are never written literally in the file, so reading the script cannot inject markup into anyone's session or editor buffer. Case 4 (one parameter with a nested block in its value): the call is delivered as `bash` with `command` cut after the nested closing tag, the rest of the model's text comes back as `content`, and the counters read `unread=0 rescued=0 refused=0`. Case 4b is the same input with `recover=True`: identical output. In prose (the tags are written as `«tool_call»`, `«/parameter»` and so on here; `repro.py` prints the real strings): the intended command was ``` python3 - <<'PY' text = '«tool_call» «function=read» «parameter=path» /tmp/x «/parameter» «/function» «/tool_call»' more lines that must not be lost ``` and what the client receives is a `bash` call whose `command` stops at the nested `«/parameter»`. ### Strata version `v0.2.4.2-6-g7dd5cf18` (source checkout, `git describe`), engine 0.1.49.1. Re-verified against `main` as fetched on 2026-10-25 (`fa663fab`, 136 commits newer): `git diff 7dd5cf18 fa663fab -- serve/` is empty, i.e. nothing under `serve/` changed in between, and the script reproduces identically there. ### Graphics card, memory and system RTX 5080 16 GB · 60 GB RAM · Linux (CachyOS, kernel 7.3.0-5), Python 3.13. The reproduction itself needs no GPU, no model file and no server. ### Model, size and settings Where it was first seen: Qwen3.8-Flash-Next GGUF, IQ3_S and IQ3_XXS, 131072 context, reached through llama-swap from an agent client (Pi) with `tool_call_recovery` on. ### Logs Nothing at all is logged for this case, which is part of the report. Compare #3441's path: when a call block is *returned as text*, `serve/server.py:5599-5603` prints a `[strata] …` line with the names involved. Here the block *is* read as a call, so no counter moves and the server says nothing. ### Related issues - #210 (closed) fixed termination on the closing tags; this is the same symptom class reached from the nested-opener side, and it survives that fix. - #1058 (closed) covers openers quoted in prose (fences and inline code) - this value is inside a call already, so the fence rule does not apply. - #2037 (closed) is about fenced JSON inside a wrapper, not about values. - #3441 / #3075 are about calls that are returned as text; there the tool never runs. Here the tool runs with cut arguments, which is the dangerous difference. ### Attached: repro.py (self-contained; the markup strings are built at runtime, never literal in the file) ~~~ #!/usr/bin/env python3 """Deterministic parser-level repro of three Strata `serve` defects seen through llama-swap + Pi. Run: python3 repro.py [--repo /path/to/Strata] [--old] (--old also runs case A against the parser as of 2026-10-20, i.e. before 70f42407.) This file never contains the markup tags literally: they are built from chr(60)/chr(62) at runtime. Keep it that way - a session whose context contains them verbatim can corrupt itself (see README.md, "Why this file is written like this"). """ import argparse import importlib.util import os import subprocess import sys T, G = chr(60), chr(62) THINK_OPEN, THINK_CLOSE = f"{T}think{G}", f"{T}/think{G}" CALL_OPEN, CALL_CLOSE = f"{T}tool_call{G}", f"{T}/tool_call{G}" PARAM_CLOSE, FUNC_CLOSE = f"{T}/parameter{G}", f"{T}/function{G}" def func(name): return f"{T}function={name}{G}" def param(name): return f"{T}parameter={name}{G}" # flat (Responses spelling): OutputParser.__init__ does {t.get("name"): t for t in tools} TOOLS = [ {"name": "bash", "parameters": {"type": "object", "properties": {"command": {"type": "string"}}, "required": ["command"]}}, {"name": "read", "parameters": {"type": "object", "properties": {"path": {"type": "string"}}}}, ] def load_parser(repo, old=False): """Return (label, OutputParser, needs_extra_kwargs) for the current or the pre-70f42407 parser.""" sys.path.insert(0, repo) if not old: from serve.frontend import OutputParser return "current HEAD", OutputParser src = subprocess.run(["git", "-C", repo, "show", "70f42407^:serve/frontend.py"], capture_output=True, text=True, check=True).stdout path = "/tmp/strata_frontend_pre_70f42407.py" open(path, "w").write(src) spec = importlib.util.spec_from_file_location("strata_frontend_old", path) mod = importlib.util.module_from_spec(spec) sys.modules["strata_frontend_old"] = mod # dataclass needs the module registered spec.loader.exec_module(mod) return "70f42407^ (2026-10-20)", mod.OutputParser def run(cls, text, tools=TOOLS, declared_only=True, recover=False, chunk=7): kw = {} try: # pre-70f42407 has no declared_only / recover p = cls(thinking=True, tools=tools, stream_tools=False, recover=recover, declared_only=declared_only) except TypeError: p = cls(thinking=True, tools=tools, stream_tools=False) evs = [] for i in range(0, len(text), chunk): # stream in small deltas, like a real server feed evs += p.feed(text[i:i + chunk]) evs += p.finish("stop") return evs, p def show(title, evs, p, expect, bug=False): """expect(calls, content_text, reasoning_text, parser) -> True when the case behaved as claimed. bug=True means the claimed behaviour is the defect, so True prints REPRODUCED.""" calls = [e.call for e in evs if e.kind == "tool_call"] text = "".join(e.text for e in evs if e.kind == "content") reasoning = "".join(e.text for e in evs if e.kind == "reasoning") ok = expect(calls, text, reasoning, p) if bug: verdict = "REPRODUCED" if ok else "*** DID NOT REPRODUCE ***" else: verdict = "as intended" if ok else "*** REGRESSION / CHANGED BEHAVIOUR ***" print(f"\n=== {title}\n {verdict}") print(f" reasoning: {reasoning[:70]!r}") print(f" content : {text[:160]!r}") print(f" calls : {[(c.name, c.arguments) for c in calls]}") print(f" unread : {getattr(p, 'unread', 'n/a (pre-70f42407)')} " f"{getattr(p, 'unread_names', '')} rescued={p.rescued} refused={p.refused}") def main(): ap = argparse.ArgumentParser() ap.add_argument("--repo", default=os.environ.get("STRATA", os.path.expanduser("~/pg/Strata"))) ap.add_argument("--old", action="store_true", help="also compare against the pre-70f42407 parser") a = ap.parse_args() label, cls = load_parser(a.repo) print(f"Strata repo: {a.repo} parser: {label}") # 0. sanity: a clean, well-formed, declared call parses clean = (f"{THINK_OPEN}\nLet me run it.\n{THINK_CLOSE}\n\n" f"{CALL_OPEN}\n{func('bash')}\n{param('command')}\nls\n{PARAM_CLOSE}\n{FUNC_CLOSE}\n{CALL_CLOSE}") evs, p = run(cls, clean) show("0. sanity - clean declared call (must parse as a call)", evs, p, lambda c, t, r, p: len(c) == 1 and c[0].name == "bash" and c[0].arguments == {"command": "ls"}) # 1. CONTROL: a think-close quoted with backticks inside the thinking stays reasoning text (#537) quoted = (f"{THINK_OPEN}\nI wrote `{THINK_CLOSE}` inside my reasoning\n" f"and kept thinking here\n{THINK_CLOSE}\n\nall done") evs, p = run(cls, quoted) show("1. control - quoted think-close in thinking (#537 protects this)", evs, p, lambda c, t, r, p: "kept thinking" in r and "kept thinking" not in t) # 2. DEFECT B: the same tag at line start ends the reasoning block; the rest leaks as content leak = (f"{THINK_OPEN}\nfirst part of the reasoning\n{THINK_CLOSE}\n" f"second part of the reasoning leaks into the answer\n{THINK_CLOSE}\n\nthe answer") evs, p = run(cls, leak) show("2. DEFECT B - bare think-close mid-thinking leaks the rest as visible content", evs, p, lambda c, t, r, p: "leaks into the answer" in t, bug=True) # 3. DEFECT A: a well-formed call for a tool the request did not declare comes back as text undeclared = (f"{THINK_OPEN}\nplan\n{THINK_CLOSE}\n\n{CALL_OPEN}\n{func('AskUserQuestion')}\n" f"{param('questions')}\n[]{PARAM_CLOSE}\n{FUNC_CLOSE}\n{CALL_CLOSE}") evs, p = run(cls, undeclared) show("3. DEFECT A - call for an undeclared name returns as text, loop cannot continue", evs, p, lambda c, t, r, p: not c and "AskUserQuestion" in t and p.unread == 1, bug=True) # 4. DEFECT C: literal call markup inside a parameter value truncates the call silently inner = (f"python3 - <<'EOF'\ntext = '''{CALL_OPEN}\n{func('read')}\n" f"{param('path')}\n/tmp/x\n{PARAM_CLOSE}") trunc = (f"{THINK_OPEN}\nplan\n{THINK_CLOSE}\n\n{CALL_OPEN}\n{func('bash')}\n{param('command')}\n" f"{inner}\n{PARAM_CLOSE}\n{FUNC_CLOSE}\n{CALL_CLOSE}\nok") evs, p = run(cls, trunc) show("4. DEFECT C - markup in an argument value truncates args silently (unread stays 0)", evs, p, lambda c, t, r, p: len(c) == 1 and "EOF" in str(c[0].arguments) and not str(c[0].arguments).endswith("EOF'\n") and p.unread == 0, bug=True) evs, p = run(cls, trunc, recover=True) show("4b. DEFECT C with tool_call_recovery=True (does NOT help)", evs, p, lambda c, t, r, p: len(c) == 1 and p.unread == 0, bug=True) # 5. Not a defect, but the answer to "is replayed thinking the cause?": think-tags in a replayed # assistant message ARE masked by mark_think_literals; tool-call literals deliberately are not. from serve.frontend import mark_think_literals, literal_tags def ctrl(name): # control tokens are never spelled literally either return chr(60) + chr(124) + name + chr(124) + chr(62) tags = literal_tags((ctrl("im_start"), ctrl("im_end"))) msgs = [{"role": "assistant", "content": "answer", "reasoning_content": f"I wrote\n{THINK_CLOSE}\nand also {CALL_OPEN} bare in my thinking"}] out, _, changed = mark_think_literals(msgs, None, tags) rc = out[0]["reasoning_content"] print("\n=== 5. input side: mark_think_literals on a replayed assistant message") print(f" changed: {changed}") print(f" think-close masked in reasoning_content : {THINK_CLOSE not in rc}") print(f" tool_call-open masked in assistant msg : {CALL_OPEN not in rc}" " <- False is intentional (frontend.py:366)") if a.old: olabel, ocls = load_parser(a.repo, old=True) evs, p = run(ocls, undeclared) show(f"6. DEFECT A on parser {olabel} - same input, different behaviour", evs, p, lambda c, t, r, p: len(c) == 1 and c[0].name == "AskUserQuestion", bug=True) if __name__ == "__main__": main() ~~~
Author
Owner

@github-actions[bot] commented on GitHub (Oct 25, 2026):

Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing:

  • Fill in "Area".
  • Fill in "Desktop app, Terminal or source?".
  • Fill in "Reproduction status".

Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment /reopen.

Details: CONTRIBUTING.md

<!-- gh-comment-id:6396331589 --> @github-actions[bot] commented on GitHub (Oct 25, 2026): Thanks for the issue. To keep the tracker readable, every item needs an area prefix in the title and the parts of the issue form filled in. This one is missing: - [ ] Fill in "Area". - [ ] Fill in "Desktop app, Terminal or source?". - [ ] Fill in "Reproduction status". Edit the issue (title and description) and this note goes away on its own. If it is still missing parts in 5 days it will be closed, which is not a rejection: fix it and comment `/reopen`. Details: [CONTRIBUTING.md](https://github.com/Niko1221/Strata/blob/main/CONTRIBUTING.md)
Author
Owner

@Tsury commented on GitHub (Oct 25, 2026):

Reproduced on hardware and proposed a fix in #4132.

RTX 5090 Laptop GPU, Qwen3.8 Flash-Next IQ3_S, a downstream v0.2.4.1 build (engine 0.1.49.1). The model was asked to copy a literal value into one tool call. Chat, Chat streaming and streaming Responses all lost bytes when the value quoted a whole tool call, repeated </parameter> + <parameter=content>, or was a heredoc that prints a quoted call. Replaying the raw model output through the parser showed that the model copied correctly and the parser cut the value.

With the #4132 change on a v0.2.6 build, those cases came back exact on all three routes (one model copy slip on a streamed heredoc at T=1.0). A bare </parameter> or </function> inside a value was already exact before and stays exact.

#4132 does not cover #4077 (a bare-line closing think tag ends reasoning early); that case still gave no tool call here.

<!-- gh-comment-id:6401201477 --> @Tsury commented on GitHub (Oct 25, 2026): Reproduced on hardware and proposed a fix in #4132. RTX 5090 Laptop GPU, Qwen3.8 Flash-Next IQ3_S, a downstream v0.2.4.1 build (engine 0.1.49.1). The model was asked to copy a literal value into one tool call. Chat, Chat streaming and streaming Responses all lost bytes when the value quoted a whole tool call, repeated `</parameter>` + `<parameter=content>`, or was a heredoc that prints a quoted call. Replaying the raw model output through the parser showed that the model copied correctly and the parser cut the value. With the #4132 change on a v0.2.6 build, those cases came back exact on all three routes (one model copy slip on a streamed heredoc at T=1.0). A bare `</parameter>` or `</function>` inside a value was already exact before and stays exact. #4132 does not cover #4077 (a bare-line closing think tag ends reasoning early); that case still gave no tool call here.
Author
Owner

@LispEngineer commented on GitHub (Oct 27, 2026):

Confirmed locally on released v0.2.7, commit 5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d (engine 0.1.52). The same probe also reproduces on v0.2.3, commit 5c8dd322528cc84f68f461ad54a506b9da8fa8d4.

This is an independent parser-level reproduction, using Linux/Python 3.14.8, with OutputParser(stream_tools=True, recover=True). No model, GPU request, live HTTP server or tool execution is involved. Both source trees have no tracked modifications.

For each value, the input is fed in chunks of 1 character, 7 characters, and the entire call:

Value v0.2.3 exact argument v0.2.7 exact argument
Ordinary multiline string 3/3 3/3
String containing a complete nested call 0/3 0/3
String reopening its own parameter 0/3 0/3

In all six failing checks per version, a tool call is emitted and unread remains 0. The nested-call case loses the tail of the intended value; the reopened-parameter case loses the first part. The expected result is one write_file call whose path and content exactly match the supplied strings.

Here is the small probe used for this confirmation. Save it outside the checkout as /tmp/strata-parser-repro.py, then run from the Strata checkout using its Python environment:

.venv/bin/python -B /tmp/strata-parser-repro.py

It prints the actual arguments for every case and exits 1 when any argument differs (the observed result on both versions).

Standalone parser probe
from pathlib import Path
import json, sys
sys.path.insert(0, str(Path.cwd()))
from serve.frontend import OutputParser

def tag(s):
    return chr(60) + s + chr(62)

tool = {"name": "write_file", "parameters": {"type": "object", "properties": {
    "path": {"type": "string"}, "content": {"type": "string"}},
    "required": ["path", "content"]}}
inner = (tag("tool_call") + tag("function=read") + tag("parameter=path")
         + "nested.txt" + tag("/parameter") + tag("/function") + tag("/tool_call"))
values = {
    "ordinary": "first line\nlast line",
    "nested_call": "first line\n" + inner + "\nlast line",
    "reopened_parameter": "first line\n" + tag("/parameter")
                          + tag("parameter=content") + "\nlast line",
}
failed = False
for name, value in values.items():
    raw = (tag("tool_call") + tag("function=write_file") + tag("parameter=path")
           + "fixture.txt" + tag("/parameter") + tag("parameter=content") + value
           + tag("/parameter") + tag("/function") + tag("/tool_call"))
    for chunk in (1, 7, len(raw)):
        parser = OutputParser(thinking=False, tools=[tool], stream_tools=True, recover=True)
        events = []
        for pos in range(0, len(raw), chunk):
            events.extend(parser.feed(raw[pos:pos + chunk]))
        events.extend(parser.finish())
        calls = [{"name": e.call.name, "arguments": e.call.arguments}
                 for e in events if e.kind == "tool_call"]
        exact = calls == [{"name": "write_file", "arguments": {
            "path": "fixture.txt", "content": value}}]
        failed |= not exact
        print(json.dumps({"case": name, "chunk": chunk, "exact": exact,
                          "unread": parser.unread, "calls": calls}))
raise SystemExit(1 if failed else 0)

This adds released-v0.2.7 confirmation to the existing report. I have not tested the #4132 branch, so this is not validation of that proposed fix, nor a claim that the defect was newly introduced in 0.2.7.

Prepared with Codex for Douglas P. Fields, Jr.

<!-- gh-comment-id:6452458602 --> @LispEngineer commented on GitHub (Oct 27, 2026): Confirmed locally on released **v0.2.7**, commit `5e8a4cca7d690ac60ca37eb09e7d0e010099ad6d` (engine 0.1.52). The same probe also reproduces on v0.2.3, commit `5c8dd322528cc84f68f461ad54a506b9da8fa8d4`. This is an independent **parser-level reproduction**, using Linux/Python 3.14.8, with `OutputParser(stream_tools=True, recover=True)`. No model, GPU request, live HTTP server or tool execution is involved. Both source trees have no tracked modifications. For each value, the input is fed in chunks of 1 character, 7 characters, and the entire call: | Value | v0.2.3 exact argument | v0.2.7 exact argument | |---|---:|---:| | Ordinary multiline string | 3/3 | 3/3 | | String containing a complete nested call | 0/3 | 0/3 | | String reopening its own parameter | 0/3 | 0/3 | In all six failing checks per version, a tool call is emitted and `unread` remains **0**. The nested-call case loses the tail of the intended value; the reopened-parameter case loses the first part. The expected result is one `write_file` call whose `path` and `content` exactly match the supplied strings. Here is the small probe used for this confirmation. Save it outside the checkout as `/tmp/strata-parser-repro.py`, then run from the Strata checkout using its Python environment: ```sh .venv/bin/python -B /tmp/strata-parser-repro.py ``` It prints the actual arguments for every case and exits 1 when any argument differs (the observed result on both versions). <details> <summary>Standalone parser probe</summary> ```python from pathlib import Path import json, sys sys.path.insert(0, str(Path.cwd())) from serve.frontend import OutputParser def tag(s): return chr(60) + s + chr(62) tool = {"name": "write_file", "parameters": {"type": "object", "properties": { "path": {"type": "string"}, "content": {"type": "string"}}, "required": ["path", "content"]}} inner = (tag("tool_call") + tag("function=read") + tag("parameter=path") + "nested.txt" + tag("/parameter") + tag("/function") + tag("/tool_call")) values = { "ordinary": "first line\nlast line", "nested_call": "first line\n" + inner + "\nlast line", "reopened_parameter": "first line\n" + tag("/parameter") + tag("parameter=content") + "\nlast line", } failed = False for name, value in values.items(): raw = (tag("tool_call") + tag("function=write_file") + tag("parameter=path") + "fixture.txt" + tag("/parameter") + tag("parameter=content") + value + tag("/parameter") + tag("/function") + tag("/tool_call")) for chunk in (1, 7, len(raw)): parser = OutputParser(thinking=False, tools=[tool], stream_tools=True, recover=True) events = [] for pos in range(0, len(raw), chunk): events.extend(parser.feed(raw[pos:pos + chunk])) events.extend(parser.finish()) calls = [{"name": e.call.name, "arguments": e.call.arguments} for e in events if e.kind == "tool_call"] exact = calls == [{"name": "write_file", "arguments": { "path": "fixture.txt", "content": value}}] failed |= not exact print(json.dumps({"case": name, "chunk": chunk, "exact": exact, "unread": parser.unread, "calls": calls})) raise SystemExit(1 if failed else 0) ``` </details> This adds released-v0.2.7 confirmation to the existing report. I have **not tested the #4132 branch**, so this is not validation of that proposed fix, nor a claim that the defect was newly introduced in 0.2.7. Prepared with Codex for Douglas P. Fields, Jr.
Author
Owner

@github-actions[bot] commented on GitHub (Oct 28, 2026):

Thanks, this follows the format now.

<!-- gh-comment-id:6464211234 --> @github-actions[bot] commented on GitHub (Oct 28, 2026): Thanks, this follows the format now.
Author
Owner

@ackalker commented on GitHub (Oct 28, 2026):

Independent parser-level confirmation on the current release, and what PR #4132 does against the same probe. Everything below is my own run; no model, no GPU, no live server and no tool was executed.

Revision and environment. main at 5e8a4cca (v0.2.7, engine 0.1.52), checkout with no local modifications. Linux (CachyOS, kernel 7.3.0-5), Python 3.14.8, 60 GB RAM. Tags below are written as «tool_call», «/parameter» and so on; the attached script builds them at runtime from chr(60) / chr(62) and never contains them literally.

Passed - the defect reproduces on released v0.2.7. Both shapes from the report come back with the wrong argument, at chunk sizes 1, 7 and the whole call, with tool_call_recovery off and on:

  • a value that contains a complete «tool_call» … «/tool_call» block (a heredoc that prints one);
  • a value that contains «/parameter» and then reopens «parameter=command» with the same name.

Expected: one call whose argument equals the input byte for byte. Got: the value cut (tail lost in the first shape, head lost in the second), and parser.unread stays 0 in every case: four combinations (two shapes, recovery off and on) at three chunk sizes, twelve runs, all wrong.

Nothing in serve/ touched value termination since the report: serve/frontend.py changed in fa663fab..5e8a4cca only in fd8d37e9 (#3972 namespaced tool spellings), 11237f83 (#3395 tool-result order) and 805ebe17 (#3796 undeclared-name wording and the collapsed mcp__a__b alias). So the report's git diff 7dd5cf18 fa663fab -- serve/ finding still holds in effect.

Passed - PR #4132 fixes this issue. git fetch origin pull/4132/head (831bb12b), same probe, same environment: the argument is exact in both shapes at all three chunk sizes, with recovery off and on. The two rules in that PR are enough for what this issue reports.

Not run. No model and no GPU, so no end-to-end server confirmation from me (another reporter has that on an RTX 5090). No CUDA, HIP, SYCL or Metal build - the change touches only serve/frontend.py. Windows not tested.

On PR #4132's red CI. Its run fails on one test only, serve/test_responses.py NoLeakedSampler.test_server_close_ends_the_sampler, which the author lists under Failed as timing-dependent; the same runner log also shows ggml_vulkan: ErrorDeviceLost and engine verify: timed out at layer 18. Nothing in that failure points at this patch.

Probe, saved outside the checkout and run as python3 -B /tmp/strata-parser-probe.py from the repository root:

parser probe
#!/usr/bin/env python3
"""Parser-level probe of #4077 and #4078 (tags built at runtime, never literal in this file)."""
import argparse, os, sys

T, G = chr(60), chr(62)
THINK_OPEN, THINK_CLOSE = f"{T}think{G}", f"{T}/think{G}"
CALL_OPEN, CALL_CLOSE = f"{T}tool_call{G}", f"{T}/tool_call{G}"
PARAM_CLOSE, FUNC_CLOSE = f"{T}/parameter{G}", f"{T}/function{G}"
def func(n): return f"{T}function={n}{G}"
def param(n): return f"{T}parameter={n}{G}"

TOOLS = [{"name": "bash", "parameters": {"type": "object",
         "properties": {"command": {"type": "string"}}, "required": ["command"]}}]

def run(cls, text, chunk=7, **kw):
    p = cls(thinking=True, tools=TOOLS, stream_tools=False, **kw)
    evs = []
    for i in range(0, len(text), chunk):
        evs += p.feed(text[i:i + chunk])
    evs += p.finish("stop")
    return evs, p

def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--repo", default=".")
    a = ap.parse_args()
    sys.path.insert(0, a.repo)
    from serve.frontend import OutputParser
    print("repo:", os.path.realpath(a.repo))

    # 4077: bare think-close at line start inside reasoning
    leak = (f"{THINK_OPEN}\nfirst part of the reasoning\n{THINK_CLOSE}\n"
            f"second part leaks into the answer\n{THINK_CLOSE}\n\nthe answer")
    evs, p = run(OutputParser, leak)
    r = "".join(e.text for e in evs if e.kind == "reasoning")
    t = "".join(e.text for e in evs if e.kind == "content")
    print(f"#4077 leak-as-content: {'REPRODUCES' if 'leaks into the answer' in t else 'fixed'}"
          f"  reasoning={r!r} content={t!r} unread={p.unread}")

    # 4077 control: quoted closer stays reasoning (#537)
    quoted = (f"{THINK_OPEN}\nI wrote `{THINK_CLOSE}` inside my reasoning\n"
              f"and kept thinking here\n{THINK_CLOSE}\n\nall done")
    evs, p = run(OutputParser, quoted)
    r = "".join(e.text for e in evs if e.kind == "reasoning")
    t = "".join(e.text for e in evs if e.kind == "content")
    print(f"#4077 control (quoted, must stay reasoning): "
          f"{'ok' if 'kept thinking' in r and 'kept thinking' not in t else 'REGRESSION'}")

    # 4078: markup inside a parameter value; expect the value byte for byte
    nested = (f"{CALL_OPEN}\n{func('read')}\n{param('path')}\nnested.txt\n"
              f"{PARAM_CLOSE}\n{FUNC_CLOSE}\n{CALL_CLOSE}")
    heredoc = (f"python3 - <<'PY'\ntext = '{nested}'\n"
               f"print('tail that must not be lost')\nPY")
    reopened = "first line\n" + PARAM_CLOSE + "\n" + param("command") + "\nlast line"
    for name, value in (("nested_call", heredoc), ("reopened_param", reopened)):
        raw = f"{CALL_OPEN}\n{func('bash')}\n{param('command')}\n{value}\n{PARAM_CLOSE}\n{FUNC_CLOSE}\n{CALL_CLOSE}"
        for label, kw in (("recover=False", {}), ("recover=True", {"recover": True})):
            out = []
            for chunk in (1, 7, len(raw)):
                evs, p = run(OutputParser, raw, chunk=chunk, **kw)
                calls = [(c.name, c.arguments) for c in
                         [e.call for e in evs if e.kind == "tool_call"]]
                out.append(calls == [("bash", {"command": value})])
            print(f"#4078 {name} ({label}): "
                  f"{'REPRODUCES (all chunk sizes fail)' if not any(out) else 'fixed ' + str(out)}"
                  f"  unread={p.unread}")

if __name__ == "__main__":
    main()

Example of the failing output on 5e8a4cca:

#4078 nested_call (recover=False): REPRODUCES (all chunk sizes fail)  unread=0
#4078 nested_call (recover=True): REPRODUCES (all chunk sizes fail)  unread=0
#4078 reopened_param (recover=False): REPRODUCES (all chunk sizes fail)  unread=0
#4078 reopened_param (recover=True): REPRODUCES (all chunk sizes fail)  unread=0

and on PR #4132:

#4078 nested_call (recover=False): fixed [True, True, True]  unread=0
#4078 nested_call (recover=True): fixed [True, True, True]  unread=0
#4078 reopened_param (recover=False): fixed [True, True, True]  unread=0
#4078 reopened_param (recover=True): fixed [True, True, True]  unread=0
<!-- gh-comment-id:6464233242 --> @ackalker commented on GitHub (Oct 28, 2026): Independent parser-level confirmation on the current release, and what PR #4132 does against the same probe. Everything below is my own run; no model, no GPU, no live server and no tool was executed. **Revision and environment.** `main` at `5e8a4cca` (v0.2.7, engine 0.1.52), checkout with no local modifications. Linux (CachyOS, kernel 7.3.0-5), Python 3.14.8, 60 GB RAM. Tags below are written as `«tool_call»`, `«/parameter»` and so on; the attached script builds them at runtime from `chr(60)` / `chr(62)` and never contains them literally. **Passed - the defect reproduces on released v0.2.7.** Both shapes from the report come back with the wrong argument, at chunk sizes 1, 7 and the whole call, with `tool_call_recovery` off and on: - a value that contains a complete `«tool_call» … «/tool_call»` block (a heredoc that prints one); - a value that contains `«/parameter»` and then reopens `«parameter=command»` with the same name. Expected: one call whose argument equals the input byte for byte. Got: the value cut (tail lost in the first shape, head lost in the second), and `parser.unread` stays `0` in every case: four combinations (two shapes, recovery off and on) at three chunk sizes, twelve runs, all wrong. Nothing in `serve/` touched value termination since the report: `serve/frontend.py` changed in `fa663fab..5e8a4cca` only in `fd8d37e9` (#3972 namespaced tool spellings), `11237f83` (#3395 tool-result order) and `805ebe17` (#3796 undeclared-name wording and the collapsed `mcp__a__b` alias). So the report's `git diff 7dd5cf18 fa663fab -- serve/` finding still holds in effect. **Passed - PR #4132 fixes this issue.** `git fetch origin pull/4132/head` (`831bb12b`), same probe, same environment: the argument is exact in both shapes at all three chunk sizes, with recovery off and on. The two rules in that PR are enough for what this issue reports. **Not run.** No model and no GPU, so no end-to-end server confirmation from me (another reporter has that on an RTX 5090). No CUDA, HIP, SYCL or Metal build - the change touches only `serve/frontend.py`. Windows not tested. **On PR #4132's red CI.** Its run fails on one test only, `serve/test_responses.py` `NoLeakedSampler.test_server_close_ends_the_sampler`, which the author lists under **Failed** as timing-dependent; the same runner log also shows `ggml_vulkan: ErrorDeviceLost` and engine `verify: timed out at layer 18`. Nothing in that failure points at this patch. Probe, saved outside the checkout and run as `python3 -B /tmp/strata-parser-probe.py` from the repository root: <details> <summary>parser probe</summary> ```python #!/usr/bin/env python3 """Parser-level probe of #4077 and #4078 (tags built at runtime, never literal in this file).""" import argparse, os, sys T, G = chr(60), chr(62) THINK_OPEN, THINK_CLOSE = f"{T}think{G}", f"{T}/think{G}" CALL_OPEN, CALL_CLOSE = f"{T}tool_call{G}", f"{T}/tool_call{G}" PARAM_CLOSE, FUNC_CLOSE = f"{T}/parameter{G}", f"{T}/function{G}" def func(n): return f"{T}function={n}{G}" def param(n): return f"{T}parameter={n}{G}" TOOLS = [{"name": "bash", "parameters": {"type": "object", "properties": {"command": {"type": "string"}}, "required": ["command"]}}] def run(cls, text, chunk=7, **kw): p = cls(thinking=True, tools=TOOLS, stream_tools=False, **kw) evs = [] for i in range(0, len(text), chunk): evs += p.feed(text[i:i + chunk]) evs += p.finish("stop") return evs, p def main(): ap = argparse.ArgumentParser() ap.add_argument("--repo", default=".") a = ap.parse_args() sys.path.insert(0, a.repo) from serve.frontend import OutputParser print("repo:", os.path.realpath(a.repo)) # 4077: bare think-close at line start inside reasoning leak = (f"{THINK_OPEN}\nfirst part of the reasoning\n{THINK_CLOSE}\n" f"second part leaks into the answer\n{THINK_CLOSE}\n\nthe answer") evs, p = run(OutputParser, leak) r = "".join(e.text for e in evs if e.kind == "reasoning") t = "".join(e.text for e in evs if e.kind == "content") print(f"#4077 leak-as-content: {'REPRODUCES' if 'leaks into the answer' in t else 'fixed'}" f" reasoning={r!r} content={t!r} unread={p.unread}") # 4077 control: quoted closer stays reasoning (#537) quoted = (f"{THINK_OPEN}\nI wrote `{THINK_CLOSE}` inside my reasoning\n" f"and kept thinking here\n{THINK_CLOSE}\n\nall done") evs, p = run(OutputParser, quoted) r = "".join(e.text for e in evs if e.kind == "reasoning") t = "".join(e.text for e in evs if e.kind == "content") print(f"#4077 control (quoted, must stay reasoning): " f"{'ok' if 'kept thinking' in r and 'kept thinking' not in t else 'REGRESSION'}") # 4078: markup inside a parameter value; expect the value byte for byte nested = (f"{CALL_OPEN}\n{func('read')}\n{param('path')}\nnested.txt\n" f"{PARAM_CLOSE}\n{FUNC_CLOSE}\n{CALL_CLOSE}") heredoc = (f"python3 - <<'PY'\ntext = '{nested}'\n" f"print('tail that must not be lost')\nPY") reopened = "first line\n" + PARAM_CLOSE + "\n" + param("command") + "\nlast line" for name, value in (("nested_call", heredoc), ("reopened_param", reopened)): raw = f"{CALL_OPEN}\n{func('bash')}\n{param('command')}\n{value}\n{PARAM_CLOSE}\n{FUNC_CLOSE}\n{CALL_CLOSE}" for label, kw in (("recover=False", {}), ("recover=True", {"recover": True})): out = [] for chunk in (1, 7, len(raw)): evs, p = run(OutputParser, raw, chunk=chunk, **kw) calls = [(c.name, c.arguments) for c in [e.call for e in evs if e.kind == "tool_call"]] out.append(calls == [("bash", {"command": value})]) print(f"#4078 {name} ({label}): " f"{'REPRODUCES (all chunk sizes fail)' if not any(out) else 'fixed ' + str(out)}" f" unread={p.unread}") if __name__ == "__main__": main() ``` </details> Example of the failing output on `5e8a4cca`: ``` #4078 nested_call (recover=False): REPRODUCES (all chunk sizes fail) unread=0 #4078 nested_call (recover=True): REPRODUCES (all chunk sizes fail) unread=0 #4078 reopened_param (recover=False): REPRODUCES (all chunk sizes fail) unread=0 #4078 reopened_param (recover=True): REPRODUCES (all chunk sizes fail) unread=0 ``` and on PR #4132: ``` #4078 nested_call (recover=False): fixed [True, True, True] unread=0 #4078 nested_call (recover=True): fixed [True, True, True] unread=0 #4078 reopened_param (recover=False): fixed [True, True, True] unread=0 #4078 reopened_param (recover=True): fixed [True, True, True] unread=0 ```
Author
Owner

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

Thank you for the probes. Fixed on our side; the fix ships in the next update (0.2.8). The fix is Tsury's change from #4132, taken as written (both commits, author kept): a value that holds a whole quoted call, or repeats </parameter> and <parameter=content>, now comes back byte for byte, whole and streamed, at any chunk size. Both shapes are in the corpus test.

<!-- gh-comment-id:6492070641 --> @Niko1221 commented on GitHub (Oct 29, 2026): Thank you for the probes. Fixed on our side; the fix ships in the next update (0.2.8). The fix is Tsury's change from #4132, taken as written (both commits, author kept): a value that holds a whole quoted call, or repeats `</parameter>` and `<parameter=content>`, now comes back byte for byte, whole and streamed, at any chunk size. Both shapes are in the corpus test.
Author
Owner

@ackalker commented on GitHub (Oct 29, 2026):

Thank you all very much for looking into this. I'm looking forward to the fix.

<!-- gh-comment-id:6507244495 --> @ackalker commented on GitHub (Oct 29, 2026): Thank you all very much for looking into this. I'm looking forward to the fix.
Author
Owner

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

Fixed in 0.2.8 with Tsury's change from #4132 (both commits, author kept): a value that holds a whole quoted call, or repeats </parameter>, now comes back byte for byte, whole and streamed. Run strata update. Closing.

<!-- gh-comment-id:6510331031 --> @Niko1221 commented on GitHub (Oct 29, 2026): Fixed in 0.2.8 with Tsury's change from #4132 (both commits, author kept): a value that holds a whole quoted call, or repeats `</parameter>`, now comes back byte for byte, whole and streamed. Run `strata update`. Closing.
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#1774
No description provided.