{"record":{"id":"c569626fa8c9b514","repo":"sgl-project/sglang","slug":"anthropic-thinking-is-not-supported-for-reasoning","errorCode":null,"errorMessage":"Anthropic thinking is not supported for reasoning parser '{self.reasoning_parser}'","messagePattern":"Anthropic thinking is not supported for reasoning parser '(.+?)'","errorType":"validation","errorClass":"ValueError","httpStatus":400,"severity":"error","filePath":"python/sglang/srt/entrypoints/openai/serving_chat.py","lineNumber":2421,"sourceCode":"            return\n\n        toggle_param = self._get_reasoning_toggle_param()\n        # The read side (``_get_reasoning_from_request``) returns False\n        # whenever ``config.toggle_param is None`` OR\n        # ``config.default_enabled is None``. The write side must mirror\n        # both conditions: if ``default_enabled`` is unset we cannot\n        # actually honor an ``enabled=True`` request even when the toggle\n        # name itself is resolvable, so writing the kwarg would set up the\n        # template to emit reasoning tokens while the parser ignores them\n        # (literal ``<think>`` markers leak into the assistant text).\n        config = self.template_manager.reasoning_config\n        read_side_supported = toggle_param is not None and (\n            config is None or config.default_enabled is not None\n        )\n        if not read_side_supported:\n            if not enabled:\n                return\n            raise ValueError(\n                f\"Anthropic thinking is not supported for reasoning parser \"\n                f\"'{self.reasoning_parser}'\"\n            )\n\n        chat_template_kwargs = dict(request.chat_template_kwargs or {})\n        chat_template_kwargs[toggle_param] = enabled\n        request.chat_template_kwargs = chat_template_kwargs\n\n    def _get_reasoning_from_request(self, request: ChatCompletionRequest) -> bool:\n        \"\"\"Determine whether reasoning mode should be enabled for this request.\n\n        NOTE: This is predefined based on model's chat template\n        \"\"\"\n        if not self.reasoning_parser:\n            return False\n\n        if self.reasoning_parser == \"minimax-m3\":\n            # M3 template prefills <mm:think> for thinking_mode=enabled, so it never","sourceCodeStart":2403,"sourceCodeEnd":2439,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/entrypoints/openai/serving_chat.py#L2403-L2439","documentation":"Anthropic thinking was enabled, and although a reasoning parser is configured, the read-side toggle is unsupported: either no toggle template parameter exists (toggle_param is None) or the parser config lacks a default_enabled value. SGLang cannot map 'thinking enabled' onto a chat-template switch for this parser.","triggerScenarios":"Enabling thinking on a reasoning parser that has no template-level on/off parameter (e.g. a parser that is neither always-on nor toggleable), where config exists but default_enabled is None.","commonSituations":"Using a newer/less-common reasoning parser without toggle support; assuming all --reasoning-parser values support the Anthropic thinking flag.","solutions":["Remove the thinking parameter from the request and rely on the model's default reasoning behavior","Use a reasoning parser with toggle support (one with a configured toggle parameter/default_enabled)","Upgrade SGLang if the parser recently gained toggle support"],"exampleFix":"# before\nrequest.thinking = {\"type\": \"enabled\", \"budget_tokens\": 2048}  # non-toggleable parser\n# after\nrequest.thinking = None  # use model default","handlingStrategy":"validation","validationCode":"if thinking_enabled and parser not in TOGGLEABLE_PARSERS: thinking = None","typeGuard":"def supports_thinking_toggle(parser_cfg) -> bool:\n    return parser_cfg is not None and parser_cfg.get('default_enabled') is not None","tryCatchPattern":"except ValueError as e: if 'not supported' in str(e): resend without thinking","preventionTips":["Verify parser toggle support before enabling thinking","Upgrade SGLang for newer parser support"],"tags":["anthropic-api","reasoning","unsupported-feature"],"backgroundTag":"reasoning-toggle-unsupported","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}