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++
#278 follow-up: an Anthropic request with its own reasoning_budget_tokens still thinks
Niko1221ca85ebdee2a7
diff --git a/serve/frontend.py b/serve/frontend.pyindex edcddb79b..84310811e 100644--- a/serve/frontend.py+++ b/serve/frontend.py@@ -219,10 +219,11 @@ def anthropic_to_messages(req: dict) -> tuple[list[dict], list[dict] | None, dickwargs.update(effort_kwargs(effort))elif isinstance(thinking, dict) and thinking.get("budget_tokens"):kwargs.update(budget_effort(thinking["budget_tokens"]))- elif thinking is None:+ elif thinking is None and not req.get("reasoning_budget_tokens"):# Anthropic's thinking is opt-in. Claude Code's helper calls (a session title, a topic check) ask for none# and allow a few dozen tokens, which the model otherwise spent thinking and answered with no text at all.- # A config's reasoning_effort still applies: Service.with_shared sets output_config before this runs.+ # A config's reasoning_effort still applies: Service.with_shared sets output_config before this runs. A+ # request that gives its own reasoning_budget_tokens (#123) asks for thinking, so it thinks as before.kwargs["enable_thinking"] = Falsereturn _late_system_to_user(messages), tools, kwargsdiff --git a/serve/test_server.py b/serve/test_server.pyindex e5d311843..123e0780e 100644--- a/serve/test_server.py+++ b/serve/test_server.py@@ -65,6 +65,17 @@ class MaxTokens(unittest.TestCase):u = b.get("usage", {})return s, b, u.get("input_tokens"), u.get("output_tokens")+ def test_anthropic_thinks_only_when_asked(self):+ # #278: Anthropic's thinking is opt-in; "thinking", an effort or a reasoning_budget_tokens (#123) asks for it+ from serve.frontend import anthropic_to_messages+ msgs = [{"role": "user", "content": "u"}]+ kw = lambda **r: anthropic_to_messages({"messages": msgs, **r})[2] # noqa: E731+ self.assertEqual(kw(), {"enable_thinking": False})+ self.assertEqual(kw(thinking={"type": "disabled"}), {"enable_thinking": False})+ self.assertNotIn("enable_thinking", kw(thinking={"type": "enabled", "budget_tokens": 2048}))+ self.assertNotIn("enable_thinking", kw(output_config={"effort": "high"}))+ self.assertNotIn("enable_thinking", kw(reasoning_budget_tokens=30))+def test_count_tokens_is_the_prompt_messages_reads(self):# /v1/messages/count_tokens renders and tokenizes the same prompt /v1/messages would read, without running itmsgs = [{"role": "user", "content": "how many tokens is this?"}]