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: tool_choice required with a single tool names it (#790)
Niko12218e368af984d4
diff --git a/serve/frontend.py b/serve/frontend.pyindex 716e64f80..a6e181d25 100644--- a/serve/frontend.py+++ b/serve/frontend.py@@ -496,6 +496,8 @@ def forced_call(tool_choice, tools: list[dict] | None) -> str | None:names = {t.get("name") for t in tools or [] if isinstance(t, dict)}if kind in ("auto", "none"):return None+ if kind == "required" and len(names) == 1: # one tool to call: name it, the model cannot invent another+ kind, name = "named", next(iter(names))if kind == "required" and names:return CALL_START + "\n<function="if kind == "named" and name in names:diff --git a/serve/test_frontend.py b/serve/test_frontend.pyindex 714dee270..8d4b80df2 100644--- a/serve/test_frontend.py+++ b/serve/test_frontend.py@@ -92,3 +92,12 @@ class EmptyTurnsSwitch(unittest.TestCase):self.assertEqual(template.render(msgs), clean)with mock.patch.dict(os.environ, {"STRATA_KEEP_EMPTY_TURNS": "1"}):self.assertNotEqual(template.render(msgs), clean)+++class ForcedCallOpening(unittest.TestCase):+ def test_required_with_one_tool_names_it(self):+ from serve.frontend import forced_call+ one, two = [{"name": "a"}], [{"name": "a"}, {"name": "b"}]+ self.assertTrue(forced_call("required", one).endswith("<function=a>\n"))+ self.assertTrue(forced_call("required", two).endswith("<function="))+ self.assertIsNone(forced_call("auto", one))