Qwen3.8-Flash-Next on any consumer hardware: one-click install for Windows / Linux. Strata inference engine, OpenAI/Anthropic API on localhost, optional image input.
C++
serve: a tool call written <function= NAME> is the call NAME
Ron Forresterdd667967b93a
diff --git a/serve/frontend.py b/serve/frontend.pyindex 4a65089f4..1dccb91c7 100644--- a/serve/frontend.py+++ b/serve/frontend.py@@ -669,7 +669,7 @@ def parse_tool_call(body: str, schema: dict | None = None) -> ToolCall:body = body.strip()if not body.startswith("<function=") or ">" not in body:raise ValueError("malformed tool call: " + body[:80])- name = body[len("<function="):body.index(">")]+ name = body[len("<function="):body.index(">")].strip() # `<function= capture>`: the model's stray spacerest = body[body.index(">") + 1:]props = ((schema or {}).get("parameters") or {}).get("properties") or {}args = {}@@ -944,7 +944,7 @@ class OutputParser:if end >= 0 and (think < 0 or think >= end):call = Nonetry:- name = body[:end].strip()[len("<function="):].split(">", 1)[0]+ name = body[:end].strip()[len("<function="):].split(">", 1)[0].strip()if name in self.schemas:call = parse_tool_call(body[:end], self.schemas.get(name))except ValueError:@@ -1178,7 +1178,7 @@ class OutputParser:def _finish_call(self, body: str) -> list[Event]:"""A whole call body in the template's form -> its tool_call event. With recover, one that still does notparse is the text it is instead of an error that ends the request."""- name = body.strip()[len(FUNC_START):].split(">", 1)[0]+ name = body.strip()[len(FUNC_START):].split(">", 1)[0].strip()bare, self.bare = self.bare, Falsetry:call = parse_tool_call(body, self.schemas.get(name))diff --git a/serve/test_tool_name_space.py b/serve/test_tool_name_space.pynew file mode 100644index 000000000..32182e82d--- /dev/null+++ b/serve/test_tool_name_space.py@@ -0,0 +1,46 @@+"""serve/test_tool_name_space.py - a tool call written `<function= NAME>` (a space after the `=`) is the call NAME.++Seen live (Qwen3.8-Flash-Next IQ2_XS, Zed's agent panel): the model wrote `<function= capture>` inside its thinking;+the name was read as " capture", matched no declared tool, stayed reasoning text (#804), and the turn ended with no+call, so the agent stopped. After the thinking the same call came out named " capture", and its arguments were+typed without the tool's schema.++ python -m unittest serve.test_tool_name_space -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++# "42" for a string parameter stays a string only when the call finds its tool's schema+SCHEMA = [{"name": "capture", "parameters": {"properties": {"content": {"type": "string"}}}}]+CALL = "<tool_call>\n<function= capture>\n<parameter=content>\n42\n</parameter>\n</function>\n</tool_call>"+++def calls(text, stream_tools):+ p = OutputParser(thinking=True, tools=SCHEMA, stream_tools=stream_tools)+ evs = []+ for i in range(0, len(text), 3): # fed in small pieces, as a stream arrives+ evs += p.feed(text[i:i + 3])+ evs += p.finish("stop")+ return [(e.call.name, e.call.arguments) for e in evs if e.kind == "tool_call"]+++class SpacedName(unittest.TestCase):+ def check(self, text):+ for stream_tools in (False, True):+ with self.subTest(stream_tools=stream_tools):+ self.assertEqual(calls(text, stream_tools), [("capture", {"content": "42"})])++ def test_inside_the_thinking(self):+ self.check("Let me save this.\n" + CALL + "\n")++ def test_after_the_thinking(self):+ self.check("Saving it.</think>\n\n" + CALL)+++if __name__ == "__main__":+ unittest.main()