From 8e368af984d4aab0ea2b0af2ab23a2fa65214535 Mon Sep 17 00:00:00 2001 From: Niko1221 Date: Mon, 5 Oct 2026 12:09:52 +0200 Subject: [PATCH] serve: tool_choice required with a single tool names it (#790) --- serve/frontend.py | 2 ++ serve/test_frontend.py | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/serve/frontend.py b/serve/frontend.py index 716e64f8..a6e181d2 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\n")) + self.assertTrue(forced_call("required", two).endswith("