Kyojin: open-source engine that runs 100 GB-class open models (GLM-5.3, Qwen3.8, DeepSeek V4.1) on one desktop machine. AMD Strix Halo, NVIDIA RTX and Apple Mac. OpenAI API, built on ExLlamaV3.
Python amdapple-siliconcudadeepseekexl3exllamav3glminferencellmllm-inferencelocal-llmnvidiaopenai-apiquantizationqwenrocmstrix-halo
Hy4 serve: force tool_choice required / a named function by prefilling the call
YanissAmz0c1a6d3eaf6a
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 10e354c..ffb4616 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -4,7 +4,7 @@Hy4-flash server hotfix: tool calling, a quiet exit when the client leaves, request-parser fixes, Strix install fixes, docs.-- Tool calling (it was a 400 "not supported"): `tools` and legacy `functions`, `tool_choice` `none` / `auto` / `required` / a named function (and legacy `function_call`), assistant messages with `tool_calls`, `tool` messages with `tool_call_id`, all rendered through the GGUF chat template. Replies carry `message.tool_calls` (JSON `arguments` string, `content` null when only calls, `finish_reason` `"tool_calls"`); streamed replies carry `delta.tool_calls` (index, id and name, then the arguments). Reasoning stays in `reasoning_content`. The parser reads the model's GLM-shaped tool block (`<tool_calls>`, `<tool_call>`, `<arg_key>`, `<arg_value>`, every tag with the template suffix), types the arguments by the declared schema, and leaves a cut-off or unknown block as plain content. The template has no switch for `tool_choice`: `none` drops the tools from the prompt, a named function keeps only that tool, `required` and a named function add one instruction line to the system message (best effort).+- Tool calling (it was a 400 "not supported"): `tools` and legacy `functions`, `tool_choice` `none` / `auto` / `required` / a named function (and legacy `function_call`), assistant messages with `tool_calls`, `tool` messages with `tool_call_id`, all rendered through the GGUF chat template. Replies carry `message.tool_calls` (JSON `arguments` string, `content` null when only calls, `finish_reason` `"tool_calls"`); streamed replies carry `delta.tool_calls` (index, id and name, then the arguments). Reasoning stays in `reasoning_content`. The parser reads the model's GLM-shaped tool block (`<tool_calls>`, `<tool_call>`, `<arg_key>`, `<arg_value>`, every tag with the template suffix), types the arguments by the declared schema, and leaves a cut-off or unknown block as plain content. The template has no switch for `tool_choice`: `none` drops the tools from the prompt; `required` and a named function are forced by prefilling the assistant turn (empty think block, then `<tool_calls><tool_call>` and the function name when it is named), so the model writes only the arguments (and the name for `required`) and the reply is always a call with `finish_reason` `"tool_calls"`; a named function also keeps only that tool in the prompt.- A client that closes the stream no longer raises in `sse()` (`ClientConnectionResetError: Cannot write to closing transport`, issue #222): the generation is cancelled, one log line is printed, no traceback. Requests that are not streamed are cancelled the same way when the client leaves. An engine error after the stream began is sent as an SSE error event followed by `[DONE]` (it used to attempt a second response and leave the client hanging).- Chat request parser: all system / developer messages are merged into one leading system message instead of a 400; a last assistant message is continued (prefill), an empty one is dropped; `response_format` `json_object` / `json_schema` is a clean 400 "not supported yet" (it was silently ignored); `n` > 1 is a clean 400; an explicit `max_completion_tokens: null` no longer hides `max_tokens`; a `stream_options` that is not an object is a 400 (was a 500); null parts, null / empty text and `input_text` / `output_text` content parts are accepted; a message shape the template cannot read is a 400, never a 500.- `tools/strix_halo/env.sh` finds the HSA runtime through `rocm-sdk path --root` when `EXL3_ROCM_SDK` is unset, and stops with a clear error instead of letting torch segfault when there is none (`EXL3_ALLOW_NO_HSA=1` for CPU-only use). `hipsp/build.sh` and `ck_fmha/build_mla.sh` remove the old library first and fail when the build fails (the first ended with `ls` and could exit 0 with a stale `.so`).diff --git a/README.md b/README.mdindex a11a611..55df8e4 100644--- a/README.md+++ b/README.md@@ -94,7 +94,7 @@ curl http://localhost:8300/v1/chat/completions -H "Content-Type: application/jso### Tool calling-The Hy4-flash server speaks the OpenAI tool-calling API: `tools` (and the legacy `functions`), `tool_choice` (`none`, `auto`, `required` or a named function; the model template has no switch for it, so `required` and a named function add one instruction line to the system message and the model decides), assistant messages with `tool_calls`, and `tool` messages with the result. A reply that calls a function has `finish_reason` `"tool_calls"` and `message.tool_calls`; streamed, the calls arrive as `delta.tool_calls`. The reasoning stays in `reasoning_content`.+The Hy4-flash server speaks the OpenAI tool-calling API: `tools` (and the legacy `functions`), `tool_choice` (`none`, `auto`, `required` or a named function; `required` and a named function are forced: the reply skips the reasoning and starts with the call, the model writes only the arguments, and the name too for `required`), assistant messages with `tool_calls`, and `tool` messages with the result. A reply that calls a function has `finish_reason` `"tool_calls"` and `message.tool_calls`; streamed, the calls arrive as `delta.tool_calls`. The reasoning stays in `reasoning_content`.```bashcurl http://localhost:8300/v1/chat/completions -H "Content-Type: application/json" -d '{diff --git a/tests/test_hy4_compat_cpu.py b/tests/test_hy4_compat_cpu.pyindex ddcea81..e09dbf1 100644--- a/tests/test_hy4_compat_cpu.py+++ b/tests/test_hy4_compat_cpu.py@@ -118,11 +118,11 @@ class Parser(unittest.TestCase):self.assertEqual([m["role"] for m in r["messages"]], ["user"])self.assertEqual(r["messages"], USER)- def test_system_messages_merge_with_the_tool_instruction(self):+ def test_system_messages_merge_with_tools_declared(self):tools = [{"type": "function", "function": {"name": "f", "parameters": {"type": "object", "properties": {}}}}]r = C.parse_chat({"messages": [{"role": "system", "content": "Be brief."}, *USER, {"role": "developer", "content": "Late rule."}], "tools": tools, "tool_choice": "required"})self.assertEqual(len(r["messages"]), 2)- self.assertEqual(r["messages"][0]["content"], "Be brief.\n\nLate rule.\n\n" + C.TOOL_HINTS["required"])+ self.assertEqual(r["messages"][0]["content"], "Be brief.\n\nLate rule.")def test_only_system_messages_is_a_400(self):with self.assertRaises(C.RequestError):diff --git a/tests/test_hy4_tools_cpu.py b/tests/test_hy4_tools_cpu.pyindex 39bbe3d..ba792d6 100644--- a/tests/test_hy4_tools_cpu.py+++ b/tests/test_hy4_tools_cpu.py@@ -180,6 +180,24 @@ class Parser(unittest.TestCase):seen = o.push(v.encode(second[20:] + ENDCALLS))self.assertEqual([p["name"] for c, p in seen if c == "tool_call"], ["search"])+ def test_a_forced_call_is_parsed_from_the_prefix_and_the_generated_rest(self):+ v = self.vocabs["special tags"]+ prefix = f"{CALLS}<tool_call{TK}>get_weather"+ rest = f"<arg_key{TK}>city</arg_key{TK}><arg_value{TK}>Paris</arg_value{TK}></tool_call{TK}>{ENDCALLS}"+ for step in (1, 3, 1000):+ ids = v.encode(rest)+ o, ev = C.OutputStream(v, False, None, TOOLS, True, prefix=prefix), []+ for i in range(0, len(ids), step):+ ev += o.push(ids[i:i + step])+ ev += o.push([v.eos_id]) + o.finish()+ self.assertEqual(collect(ev), {"reasoning": "", "content": "", "calls": [("get_weather", {"city": "Paris"})]})+ self.assertEqual(o.final_reason(), "tool_calls")+ o = C.OutputStream(v, False, None, TOOLS, True, prefix=f"{CALLS}<tool_call{TK}>") # required: the model writes the name too+ ev = o.push(v.encode(f"search<arg_key{TK}>query</arg_key{TK}><arg_value{TK}>rain</arg_value{TK}></tool_call{TK}>{ENDCALLS}") + [v.eos_id]) + o.finish()+ self.assertEqual(collect(ev)["calls"], [("search", {"query": "rain"})])+ o = C.OutputStream(v, False, None, TOOLS, True, prefix=prefix) # no token at all: nothing valid, nothing lost+ self.assertEqual(collect(o.finish())["calls"], [])+def test_random_piece_sizes(self):text = f"plan{UNTHINK}Let me check.{CALLS}{call('get_weather', city='Paris')}{call('search', query='a b', limit=2)}{ENDCALLS}"rng = random.Random(7)@@ -235,16 +253,30 @@ class Request(unittest.TestCase):r = self.parse(tools=TOOLS, function_call="auto")self.assertEqual(r["tool_choice"], "auto")- def test_tool_choice_hint_goes_into_the_system_message(self):+ def test_forced_tool_choice_prefills_the_call(self):r = self.parse(tools=TOOLS, tool_choice="required")- self.assertEqual(r["messages"][0]["role"], "system")- self.assertIn("must answer by calling", r["messages"][0]["content"])- msgs = [{"role": "system", "content": "Be brief."}, {"role": "user", "content": "x"}]- r = C.parse_chat({"messages": msgs, "tools": TOOLS, "tool_choice": {"type": "function", "function": {"name": "search"}}})- self.assertTrue(r["messages"][0]["content"].startswith("Be brief.\n\n"))- self.assertIn("function search", r["messages"][0]["content"])- self.assertEqual(len(r["messages"]), 2)- self.assertEqual(self.parse(tools=TOOLS)["messages"][0]["role"], "user") # auto: the messages are untouched+ self.assertEqual((r["force"], r["effort"], r["tool_name"]), (True, "no_think", None))+ r = self.parse(tools=TOOLS, tool_choice={"type": "function", "function": {"name": "search"}}, reasoning_effort="max")+ self.assertEqual((r["force"], r["effort"], r["tool_name"]), (True, "no_think", "search"))+ self.assertEqual(r["messages"], [{"role": "user", "content": "weather in Paris?"}]) # the messages are untouched+ for choice in ("auto", "none"):+ r = self.parse(tools=TOOLS, tool_choice=choice)+ self.assertFalse(r["force"])+ self.assertEqual(r["effort"], "high")+ with self.assertRaises(C.RequestError):+ C.parse_chat({"messages": [*r["messages"], {"role": "assistant", "content": "Sure"}], "tools": TOOLS, "tool_choice": "required"})++ def test_chat_prompt_ends_with_the_forced_call_opening(self):+ r = self.parse(tools=TOOLS, tool_choice={"type": "function", "function": {"name": "get_weather"}})+ text, prefix = self.v.chat_prompt(r)+ self.assertEqual(prefix, f"{CALLS}<tool_call{TK}>get_weather")+ self.assertTrue(text.endswith(f"{START}assistant{MIDDLE}{THINK}{UNTHINK}{prefix}"))+ self.assertNotIn('"name": "search"', text) # only the named tool is declared+ text, prefix = self.v.chat_prompt(self.parse(tools=TOOLS, tool_choice="required"))+ self.assertEqual(prefix, f"{CALLS}<tool_call{TK}>")+ self.assertTrue(text.endswith(prefix))+ text, prefix = self.v.chat_prompt(self.parse(tools=TOOLS))+ self.assertEqual((prefix, text.endswith(THINK)), ("", True))def test_bad_tool_requests_are_a_400(self):bad = [dict(tools="x"), dict(tools=[1]), dict(tools=[{"type": "function"}]), dict(tools=[{"type": "function", "function": {"name": "a b"}}]),@@ -303,7 +335,7 @@ class Request(unittest.TestCase):text = self.render(messages=[{"role": "system", "content": "Be brief."}, {"role": "user", "content": "weather?"}], tools=TOOLS)self.assertLess(text.index("# Tools"), text.index("Be brief."))self.assertNotIn("# Tools", self.render(messages=[{"role": "user", "content": "x"}], tools=TOOLS, tool_choice="none"))- self.assertIn("function get_weather", self.render(messages=[{"role": "user", "content": "x"}], tools=TOOLS, tool_choice={"function": {"name": "get_weather"}}))+ self.assertNotIn('"name": "search"', self.render(messages=[{"role": "user", "content": "x"}], tools=TOOLS, tool_choice={"function": {"name": "get_weather"}}))def test_multi_turn_history_is_rendered_back_in_the_template_format(self):msgs = self.history('{"city": "Paris", "days": 2}', content="Let me check.")@@ -510,6 +542,38 @@ class Http(unittest.IsolatedAsyncioTestCase):self.assertEqual(r.status, 400, (extra, j))self.assertEqual(j["error"]["type"], "invalid_request_error")+ async def test_named_tool_choice_forces_the_call(self):+ """the model is only asked for the arguments: the prompt already ends with the call opening and the function name"""+ rest = f"<arg_key{TK}>city</arg_key{TK}><arg_value{TK}>Paris</arg_value{TK}></tool_call{TK}>{ENDCALLS}"+ for stream in (False, True):+ st = await self.start(rest)+ body = self.body(tool_choice={"type": "function", "function": {"name": "get_weather"}}, stream=stream, reasoning_effort="high")+ if stream:+ chunks = await self.sse_chunks(tool_choice=body["tool_choice"], reasoning_effort="high")+ deltas = [c["choices"][0]["delta"] for c in chunks if c["choices"]]+ tcs = [tc for d in deltas for tc in d.get("tool_calls", [])]+ self.assertEqual(tcs[0]["function"]["name"], "get_weather")+ self.assertEqual(json.loads(tcs[1]["function"]["arguments"]), {"city": "Paris"})+ self.assertEqual([c["choices"][0]["finish_reason"] for c in chunks if c["choices"]][-1], "tool_calls")+ else:+ j = await (await self.client.post("/v1/chat/completions", json=body)).json()+ ch = j["choices"][0]+ self.assertEqual(ch["finish_reason"], "tool_calls")+ self.assertIsNone(ch["message"]["content"])+ [tc] = ch["message"]["tool_calls"]+ self.assertEqual((tc["function"]["name"], json.loads(tc["function"]["arguments"])), ("get_weather", {"city": "Paris"}))+ prompt = st.vocab.decode(st.engine.calls[0][0])+ self.assertTrue(prompt.endswith(f"{UNTHINK}{CALLS}<tool_call{TK}>get_weather"), prompt[-120:])+ await self.client.close()++ async def test_required_tool_choice_forces_a_call(self):+ await self.start(f"search<arg_key{TK}>query</arg_key{TK}><arg_value{TK}>rain</arg_value{TK}></tool_call{TK}>{ENDCALLS}")+ j = await (await self.client.post("/v1/chat/completions", json=self.body(tool_choice="required", reasoning_effort="high"))).json()+ ch = j["choices"][0]+ self.assertEqual(ch["finish_reason"], "tool_calls")+ self.assertEqual(ch["message"]["tool_calls"][0]["function"]["name"], "search")+ self.assertTrue(self.st.vocab.decode(self.st.engine.calls[0][0]).endswith(f"{CALLS}<tool_call{TK}>"))+async def test_apply_template_with_tools(self):await self.start("x")j = await (await self.client.post("/apply-template", json=self.body())).json()diff --git a/tools/hy4/serve.py b/tools/hy4/serve.pyindex a8f7cd8..36a6b0d 100644--- a/tools/hy4/serve.py+++ b/tools/hy4/serve.py@@ -167,7 +167,7 @@ def build_app(st: State):def prompt_for_chat(body):r = C.parse_chat(body, args.default_max_tokens)- text = st.vocab.template.render_chat(r)+ text, r["prefix"] = st.vocab.chat_prompt(r)ids = st.vocab.encode(text)v = st.vocabr["in_think"] = not r["prefill"] and r["effort"] != "no_think" and bool(v.think_begin) and text.rstrip().endswith(v.think_begin)@@ -182,7 +182,7 @@ def build_app(st: State):from mu_engine import Requestloop = asyncio.get_running_loop()q: asyncio.Queue = asyncio.Queue()- out = C.OutputStream(st.vocab, in_think=in_think, stops=r["stop"], tools=r.get("tools"), parse_tools=r.get("parse_tools", False))+ out = C.OutputStream(st.vocab, in_think=in_think, stops=r["stop"], tools=r.get("tools"), parse_tools=r.get("parse_tools", False), prefix=r.get("prefix", ""))def on_tokens(toks):for ch, tx in out.push(toks):@@ -225,7 +225,7 @@ def build_app(st: State):returnloop = asyncio.get_running_loop()q: asyncio.Queue = asyncio.Queue()- out = C.OutputStream(st.vocab, in_think=in_think, stops=r["stop"], tools=r.get("tools"), parse_tools=r.get("parse_tools", False))+ out = C.OutputStream(st.vocab, in_think=in_think, stops=r["stop"], tools=r.get("tools"), parse_tools=r.get("parse_tools", False), prefix=r.get("prefix", ""))cancel = threading.Event()res: dict = {}@@ -407,7 +407,7 @@ def build_app(st: State):try:need_ready()r = C.parse_chat(await read_body(request), args.default_max_tokens)- return web.json_response({"prompt": st.vocab.template.render_chat(r)})+ return web.json_response({"prompt": st.vocab.chat_prompt(r)[0]})except C.RequestError as e:return _err(e.status, str(e), e.code)diff --git a/tools/hy4/serve_core.py b/tools/hy4/serve_core.pyindex 174f7f4..9450dd3 100644--- a/tools/hy4/serve_core.py+++ b/tools/hy4/serve_core.py@@ -103,6 +103,15 @@ class Vocab:self.think_end = next((t for t in toks if t.startswith("</think")), None)self.tool_tags = ToolTags(tag_suffix(self.think_begin))+ def chat_prompt(self, r: dict) -> tuple[str, str]:+ """parsed chat request -> (prompt text, forced prefix). tool_choice required / a named function: the assistant turn is prefilled with the call opening+ <tool_calls><tool_call> (and the function name when it is named); the output stream is seeded with the same text so the parser sees the whole call."""+ text = self.template.render_chat(r)+ prefix = ""+ if r.get("force"):+ prefix = self.tool_tags.calls_open + self.tool_tags.call_open + (r["tool_name"] or "")+ return text + prefix, prefix+def encode(self, text: str) -> list[int]:return self.tok.encode(text, add_special_tokens=False).ids@@ -319,15 +328,12 @@ def check_response_format(body: dict) -> None:raise RequestError("response_format.type must be text, json_object or json_schema")-TOOL_HINTS = {"required": "You must answer by calling one or more of the provided functions.",- "function": "You must answer by calling the function {name}."}--def parse_tools(body: dict) -> dict:"""`tools` (or the legacy `functions`) and `tool_choice` (or the legacy `function_call`) of a chat request ->- {tools: the declared function tools the prompt carries (None = none), tool_choice: none | auto | required | function, tool_name, parse_tools, tool_hint}.+ {tools: the declared function tools the prompt carries (None = none), tool_choice: none | auto | required | function, tool_name, parse_tools, force}.The chat template has no switch for tool_choice: "none" leaves the tools out of the prompt and the output is plain text; a named function keeps only that- tool in the prompt; "required" and a named function add one instruction line to the system message (best effort, the model decides)."""+ tool in the prompt; "required" and a named function are FORCED: `force` is True and the assistant turn is prefilled with the call opening (Vocab.chat_prompt),+ so the model can only write the arguments (named) or the call (required)."""raw = body.get("tools")if raw is None or raw == []:raw = body.get("functions")@@ -361,7 +367,7 @@ def parse_tools(body: dict) -> dict:if mode == "none":tools = []return {"tools": tools or None, "tool_choice": mode, "tool_name": name, "parse_tools": bool(tools),- "tool_hint": TOOL_HINTS.get(mode, "").format(name=name)}+ "force": mode in ("required", "function")}def _call_arguments(args: Any, where: str) -> dict:@@ -446,12 +452,14 @@ def parse_chat(body: dict, default_max: int = 1024) -> dict:raise RequestError("the last assistant message has tool_calls: add a tool message with each result")if prefill and len(out) < 2:raise RequestError("the last message must come from the user")- if req["tool_hint"]:- system.append(req["tool_hint"])if system:out.insert(0, {"role": "system", "content": "\n\n".join(system)})- req.pop("tool_hint")- req.update(messages=out, effort=parse_effort(body), prefill=prefill)+ effort = parse_effort(body)+ if req["force"]:+ if prefill:+ raise RequestError("tool_choice required / a named function cannot be combined with a last assistant message")+ effort = "no_think" # the forced call replaces the reasoning: the turn opens with an empty think block+ req.update(messages=out, effort=effort, prefill=prefill)return req@@ -516,9 +524,10 @@ class OutputStream:Stops on an EOS id (dropped) or a stop string (cut; only searched in the content channel).parse_tools: a tool block (<tool_calls> ... </tool_calls>, or a bare <tool_call> ... </tool_call>) in the content is held back and read call by call, each callleaves as a "tool_call" delta the moment its </tool_call> arrives. `tools` (the declared tools) types the arguments and names the calls that count: a block- that is not a valid call (cut off, no name, a function the request did not declare) stays plain content. A tool block is only looked for after the reasoning."""+ that is not a valid call (cut off, no name, a function the request did not declare) stays plain content. A tool block is only looked for after the reasoning.+ prefix: the forced call opening the prompt ended with; it is parsed as the first text of the reply."""- def __init__(self, vocab: Vocab, in_think: bool = False, stops: list[str] | None = None, tools: list | None = None, parse_tools: bool = False):+ def __init__(self, vocab: Vocab, in_think: bool = False, stops: list[str] | None = None, tools: list | None = None, parse_tools: bool = False, prefix: str = ""):self.v = vocabself.dec = IncrementalDecoder(vocab)self.in_think = bool(in_think and vocab.think_end)@@ -530,7 +539,7 @@ class OutputStream:self.tool_wrapped = Falseself.tool_pos = 0self.n_calls = 0- self.buf = ""+ self.buf = prefix # text the prompt already ended with (a forced tool call opening): read as the start of the replyself.done = Falseself.finish_reason: str | None = Noneself.n_tokens = 0 # generated tokens counted (EOS and anything after it excluded)diff --git a/tools/hy4/tool_smoke.py b/tools/hy4/tool_smoke.pyindex 94f55dc..c953027 100755--- a/tools/hy4/tool_smoke.py+++ b/tools/hy4/tool_smoke.py@@ -9,6 +9,7 @@ Cases (each needs the real model: the reply is whatever the model decides):2. tool call, streamed same, read from delta.tool_calls chunks (index, id + name, then the arguments)3. multi-turn round trip the call and its result are sent back -> a final text answer, finish_reason "stop"4. disconnect mid-stream close a long stream after a few chunks -> the engine is free again within a few seconds+ 5. forced tool_choice a greeting with tool_choice naming get_weather -> still a get_weather call, finish_reason "tool_calls"Standard library only (http.client): it runs in the release venv as it is."""from __future__ import annotations@@ -182,6 +183,22 @@ class Smoke:return False, f"finish_reason {ch['finish_reason']!r}, content {content[:160]!r}, tool_calls {ch['message'].get('tool_calls')}"return True, f"answer {content.strip()[:100]!r} (mentions 18: {'18' in content})"+ def case_forced(self):+ choice = {"type": "function", "function": {"name": "get_weather"}}+ r = self.post(self.body([{"role": "user", "content": "Say hello to me."}], tool_choice=choice))+ if r.status_code != 200:+ return False, f"HTTP {r.status_code}: {r.text[:200]}"+ ch = r.json()["choices"][0]+ calls = ch["message"].get("tool_calls") or []+ if ch["finish_reason"] != "tool_calls" or not calls:+ return False, f"finish_reason {ch['finish_reason']!r}, no tool_calls; content {str(ch['message'].get('content'))[:160]!r}"+ fn = calls[0]["function"]+ try:+ json.loads(fn["arguments"])+ except ValueError:+ return False, f"arguments are not JSON: {fn['arguments'][:120]!r}"+ return fn["name"] == "get_weather", f"{fn['name']}({fn['arguments']})"+def case_disconnect(self):quick = self.body([{"role": "user", "content": "Say hello in one word."}], max_tokens=16, reasoning_effort="no_think")quick.pop("tools")@@ -229,6 +246,7 @@ def main(argv=None) -> int:sm.run("2 tool call (stream)", sm.case_stream)sm.run("3 multi-turn with a tool result", sm.case_multi_turn)sm.run("4 disconnect mid-stream", sm.case_disconnect)+ sm.run("5 forced tool_choice", sm.case_forced)failed = [n for n, ok, _ in sm.results if not ok]print(f"{len(sm.results) - len(failed)}/{len(sm.results)} passed" + (f"; failed: {', '.join(failed)}" if failed else ""))return 1 if failed else 0