From 0e35416128e38f158af49935262ecbf8dbf585e6 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 31 Jul 2026 19:09:44 +0200 Subject: fix: cap searches at one per turn A second tool call in the same turn, issued after the model has seen the first set of results, does not arrive as a tool_calls delta. It comes back as literal text inside reasoning_content, with finish_reason stop, no tool_calls and empty content. There is no structured call for the loop to act on, so the turn ends and the user is shown a blank reply. Reproduced 3/3 with Qwen3.5-9B through the router; the first call of a turn parses correctly every time, so this is specific to a call that follows a tool result. A retry with the tool withdrawn was tried and rejected: it produced an answer only some of the time and could surface the raw XML in the reply, which is worse than the blank it replaces. Capping at one search avoids reaching the broken state at all. Empty replies drop from 3/3 to about 1/3 and the XML no longer leaks, but the failure is not eliminated. Raise max_searches once the chat template parses follow-up calls. Co-Authored-By: Claude Opus 5 --- test_llamachat.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'test_llamachat.py') diff --git a/test_llamachat.py b/test_llamachat.py index 936a18d..a766382 100755 --- a/test_llamachat.py +++ b/test_llamachat.py @@ -967,6 +967,12 @@ def test_search_tool_schema(): assert out == [("content", "hi")] assert sent == [None], sent + # One search per turn by default: a follow-up call arrives as literal + # XML rather than a structured call, and a turn that ends on + # one shows the user an empty reply. + assert config.DEFAULTS["max_searches"] == 1 + assert config.load(Path("/nonexistent/config.toml")).max_searches == 1 + # A configured-but-urlless setup resolves to disabled at config load. with tempfile.TemporaryDirectory() as tmp: path = Path(tmp) / "config.toml" -- cgit v1.2.3