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: log when a reply reaches max tokens still thinking, and what helps (#530)
Niko1221e685972a4724
diff --git a/serve/server.py b/serve/server.pyindex 90bad3a86..4f438e1de 100644--- a/serve/server.py+++ b/serve/server.py@@ -1587,6 +1587,10 @@ class Service:hit_msg = f", expert cache {hit_rate*100:.1f}% hit" if hit_rate is not None else ""print(f"[strata] done: {n} tokens in {el:.0f} s ({rate:.1f} tok/s) "f"({finish}, cancel={cancel.is_set()}){hit_msg}", flush=True)+ if finish == "length" and parser.state == "reasoning": # #530+ print("[strata] the reply reached max tokens while still thinking, so it has no "+ "answer: a thinking budget (reasoning_budget_tokens, in the request or in "+ "strata-<model>.json for every request) leaves room to answer", flush=True)if os.environ.get("STRATA_DEBUG") and raw_ids:print(f"[strata] raw: {self.tok.decode(raw_ids)!r}", flush=True)self.status["busy"] = Falsediff --git a/serve/test_server.py b/serve/test_server.pyindex c29edcdea..756c1f545 100644--- a/serve/test_server.py+++ b/serve/test_server.py@@ -4,6 +4,8 @@"""from __future__ import annotations+import contextlib+import ioimport jsonimport osimport sys@@ -1813,6 +1815,20 @@ class ThinkingBudget(unittest.TestCase):self.assertEqual(len(self.engine.prompts), 1)self.assertEqual(b["choices"][0]["message"]["reasoning_content"], ThinkingEngine.THOUGHT[:20])+ def test_a_reply_cut_while_thinking_is_named_in_the_log(self):+ """#530: max tokens reached inside the thinking gives an empty answer; the server log says what helps."""+ hint = "reached max tokens while still thinking"+ for extra, said in (({"max_tokens": 10}, True), ({}, False)):+ with self.subTest(extra=extra):+ out = io.StringIO()+ with contextlib.redirect_stdout(out):+ code, b = self.openai(**extra)+ self.assertEqual(code, 200, b)+ self.assertEqual(b["choices"][0]["finish_reason"], "length" if said else "stop")+ self.assertEqual(hint in out.getvalue(), said, out.getvalue())+ if said:+ self.assertIn("reasoning_budget_tokens", out.getvalue())+def test_a_bad_value_is_a_400(self):for bad in ("lots", 2.5, True, [1]):with self.subTest(value=bad):