Skip to content

armgit / sie

Public Imported from GitHub
0

Open-source inference server and production cluster for all the models your agent needs.

fix(server): read Qwen2.5-style tool calls as Hermes JSON on the queued route (#332)

Krisztian Gajdard8494f3ff964
diff --git a/packages/sie_server/src/sie_server/processors/streaming.py b/packages/sie_server/src/sie_server/processors/streaming.py
index 45a265981..26c7d414f 100644
--- a/packages/sie_server/src/sie_server/processors/streaming.py
+++ b/packages/sie_server/src/sie_server/processors/streaming.py
@@ -1150,10 +1150,11 @@ class StreamingProcessor:
Drives format selection from a single source of truth — the
adapter's ``tool_call_parser`` (the same value passed to SGLang's
``--tool-call-parser`` launch flag) — instead of guessing per
- block from the model output. ``qwen3_coder`` (and any other
- ``qwen*`` parser) → ``qwen_xml``; ``hermes`` → ``hermes_json``;
- ``glm*`` → ``glm_xml``; anything unknown / missing → ``auto`` (keep the runtime
- heuristic so out-of-tree models still work).
+ block from the model output. ``qwen25`` (Qwen2.5-style Hermes JSON)
+ and ``hermes`` → ``hermes_json``; ``qwen3_coder`` (and any other
+ ``qwen*`` parser) → ``qwen_xml``; ``glm*`` → ``glm_xml``; anything
+ unknown / missing → ``auto`` (keep the runtime heuristic so
+ out-of-tree models still work).
"""
try:
config = self._registry.get_config(model_id)
@@ -1167,10 +1168,10 @@ class StreamingProcessor:
if not isinstance(parser, str):
return "auto"
parser_l = parser.lower()
+ if parser_l == "qwen25" or "hermes" in parser_l:
+ return "hermes_json"
if parser_l.startswith("qwen"):
return "qwen_xml"
- if "hermes" in parser_l:
- return "hermes_json"
if parser_l.startswith("glm"):
return "glm_xml"
return "auto"
diff --git a/packages/sie_server/tests/processors/test_streaming.py b/packages/sie_server/tests/processors/test_streaming.py
index 03f0b7c9c..c13f8f519 100644
--- a/packages/sie_server/tests/processors/test_streaming.py
+++ b/packages/sie_server/tests/processors/test_streaming.py
@@ -2808,9 +2808,15 @@ async def test_streaming_tool_choice_required_forwards_forcing_grammar() -> None
@pytest.mark.asyncio
-async def test_streaming_glm_tool_call_is_forced_and_parsed_in_its_own_format() -> None:
+ ("parser", "call"),
+ [
+ ("glm47", "<tool_call>get_weather<arg_key>city</arg_key><arg_value>Tokyo</arg_value></tool_call>"),
+ ("qwen25", '<tool_call>\n{"name": "get_weather", "arguments": {"city": "Tokyo"}}\n</tool_call>'),
+ ],
+)
+async def test_streaming_tool_call_is_forced_and_parsed_in_the_configured_format(parser: str, call: str) -> None:
nc = AsyncMock()
- call = "<tool_call>get_weather<arg_key>city</arg_key><arg_value>Tokyo</arg_value></tool_call>"
adapter = _FakeGenAdapter(
[
GenerationChunk(text_delta=call, is_first=True),
@@ -2831,7 +2837,7 @@ async def test_streaming_glm_tool_call_is_forced_and_parsed_in_its_own_format()
adapter.generate = _capture # type: ignore[method-assign]
registry = _make_registry(adapter)
resolved = MagicMock()
- resolved.loadtime = {"tool_call_parser": "glm47"}
+ resolved.loadtime = {"tool_call_parser": parser}
registry.get_config.return_value.resolve_profile.return_value = resolved
proc = StreamingProcessor(nc=nc, registry=registry, worker_id="w1")
wi = _make_work_item(