[GH-ISSUE #4703] [Engine] Tool call parsing: a call shown as an indented (4-space) Markdown code block becomes a real call #2150

Closed
opened 2026-11-04 01:57:04 +07:00 by bsakaguchi · 1 comment
Owner

Originally created by @KarlGrier on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4703

Area

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

Desktop app, Terminal or source?

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

What happened

In serve/frontend.py's OutputParser at v0.2.8 (recover off and on).

An answer that explains the call format with an indented code block - four spaces before every line - gets a real read
call out of it, with the indentation inside the argument value.

Notes: fenced code and inline code are already treated as quotes (#804 / #1058); an indented code block (CommonMark:
four or more spaces after a blank line) is the third Markdown code form. The path value carrying the indentation shows
the call is not one the model meant to make. Treating such a block as a quote only after a blank line keeps calls the
model indents for other reasons working.

Smallest steps or command that reproduce it

Parser level - no model, no GPU, no server. From the root of a v0.2.8 checkout, with this setup:

import json
from serve.frontend import OutputParser

def tool(name, **props):
    return {"name": name, "parameters": {"type": "object", "properties": props}}

S = {"type": "string"}
TOOLS = [tool("read", path=S), tool("write_file", path=S, content=S)]

def qwen(name, **params):  # the Qwen3.8-Flash-Next call form, as in serve/test_tool_corpus.py
    body = "".join(f"<parameter={k}>\n{v}\n</parameter>\n" for k, v in params.items())
    return f"<tool_call>\n<function={name}>\n{body}</function>\n</tool_call>"

def parse(text, thinking=False):
    p = OutputParser(thinking=thinking, tools=TOOLS, stream_tools=False, recover=False, declared_only=True)
    evs = p.feed(text) + p.finish("stop")
    calls = [(e.call.name, e.call.arguments) for e in evs if e.kind == "tool_call"]
    answer = "".join(e.text for e in evs if e.kind == "content")
    return calls, answer

then:

block = "\n".join("    " + line for line in qwen("read", path="EXAMPLE.txt").split("\n"))
print(parse("The format, indented as code:\n\n" + block + "\n\nIndentation makes it a code block in Markdown."))

Observed (the same whole, byte by byte, and in pieces of 7):

([('read', {'path': '    EXAMPLE.txt\n    '})], 'The format, indented as code:\n\n    Indentation makes it a code block in Markdown.')

Expected: no call, and the whole text as the answer.

Reproduction status

Reproduced locally

Strata version

v0.2.8 (the tag, source checkout, no local modifications) · engine 0.1.54

Graphics card, memory and system

Not involved (parser level, no GPU) · Linux · Python 3.12

Model, size and settings

Not involved: the parser is fed the model's text directly (the Qwen3.8-Flash-Next call form from serve/test_tool_corpus.py).

Measured and drafted with Claude Code.

Originally created by @KarlGrier on GitHub (Oct 30, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4703 ### Area [Engine] (speed, kernels, models, the server and API) ### Desktop app, Terminal or source? Source (START-HERE.bat, setup.sh or a build) ### What happened In `serve/frontend.py`'s `OutputParser` at v0.2.8 (recover off and on). An answer that explains the call format with an indented code block - four spaces before every line - gets a real `read` call out of it, with the indentation inside the argument value. Notes: fenced code and inline code are already treated as quotes (#804 / #1058); an indented code block (CommonMark: four or more spaces after a blank line) is the third Markdown code form. The `path` value carrying the indentation shows the call is not one the model meant to make. Treating such a block as a quote only after a blank line keeps calls the model indents for other reasons working. ### Smallest steps or command that reproduce it Parser level - no model, no GPU, no server. From the root of a v0.2.8 checkout, with this setup: ```python import json from serve.frontend import OutputParser def tool(name, **props): return {"name": name, "parameters": {"type": "object", "properties": props}} S = {"type": "string"} TOOLS = [tool("read", path=S), tool("write_file", path=S, content=S)] def qwen(name, **params): # the Qwen3.8-Flash-Next call form, as in serve/test_tool_corpus.py body = "".join(f"<parameter={k}>\n{v}\n</parameter>\n" for k, v in params.items()) return f"<tool_call>\n<function={name}>\n{body}</function>\n</tool_call>" def parse(text, thinking=False): p = OutputParser(thinking=thinking, tools=TOOLS, stream_tools=False, recover=False, declared_only=True) evs = p.feed(text) + p.finish("stop") calls = [(e.call.name, e.call.arguments) for e in evs if e.kind == "tool_call"] answer = "".join(e.text for e in evs if e.kind == "content") return calls, answer ``` then: ```python block = "\n".join(" " + line for line in qwen("read", path="EXAMPLE.txt").split("\n")) print(parse("The format, indented as code:\n\n" + block + "\n\nIndentation makes it a code block in Markdown.")) ``` Observed (the same whole, byte by byte, and in pieces of 7): ``` ([('read', {'path': ' EXAMPLE.txt\n '})], 'The format, indented as code:\n\n Indentation makes it a code block in Markdown.') ``` Expected: no call, and the whole text as the answer. ### Reproduction status Reproduced locally ### Strata version v0.2.8 (the tag, source checkout, no local modifications) · engine 0.1.54 ### Graphics card, memory and system Not involved (parser level, no GPU) · Linux · Python 3.12 ### Model, size and settings Not involved: the parser is fed the model's text directly (the Qwen3.8-Flash-Next call form from serve/test_tool_corpus.py). Measured and drafted with Claude Code.
Author
Owner

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

Fixed in 0.2.9: a call inside an indented code block is now text and isn't run. The longer-fence case in #4702 is fixed too.

<!-- gh-comment-id:6541130348 --> @Niko1221 commented on GitHub (Oct 31, 2026): Fixed in [0.2.9](https://github.com/Niko1221/Strata/releases/tag/v0.2.9): a call inside an indented code block is now text and isn't run. The longer-fence case in #4702 is fixed too.
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#2150
No description provided.