{"record":{"id":"10897dcf9db19050","repo":"sgl-project/sglang","slug":"invalid-reasoning-effort-effort-r","errorCode":null,"errorMessage":"invalid reasoning effort: {effort!r}","messagePattern":"invalid reasoning effort: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/sglang/srt/entrypoints/openai/protocol.py","lineNumber":1011,"sourceCode":"            if isinstance(effort, str) and effort in {\n                \"none\",\n                \"minimal\",\n                \"low\",\n                \"medium\",\n                \"high\",\n                \"xhigh\",\n                \"max\",\n            }:\n                values[\"reasoning_effort\"] = effort\n            elif isinstance(effort, (int, float)) and not isinstance(effort, bool):\n                values[\"reasoning_effort\"] = float(effort)\n            elif isinstance(effort, str):\n                # Keep parity with the top-level reasoning_effort field, whose\n                # lax union coerces numeric strings; range checks then apply.\n                try:\n                    values[\"reasoning_effort\"] = float(effort)\n                except ValueError as exc:\n                    raise ValueError(f\"invalid reasoning effort: {effort!r}\") from exc\n            elif effort is not None:\n                raise ValueError(f\"invalid reasoning effort: {effort!r}\")\n\n            enabled = (\n                r.get(\"enabled\")\n                if r.get(\"enabled\") is not None\n                else r.get(\"enable\", False)\n            )\n            if isinstance(enabled, str):\n                enabled = enabled.strip().lower() in {\"1\", \"true\", \"yes\", \"y\", \"on\"}\n            if enabled:\n                thinking = True\n\n        effort = values.get(\"reasoning_effort\")\n        if effort is not None:\n            thinking = effort != \"none\"\n\n        if thinking is not None:","sourceCodeStart":993,"sourceCodeEnd":1029,"githubUrl":"https://github.com/sgl-project/sglang/blob/0132848349585cfe6aae51c4941cbae872505f8a/python/sglang/srt/entrypoints/openai/protocol.py#L993-L1029","documentation":"Raised by ChatCompletionRequest.normalize_reasoning_inputs when the reasoning dict's 'effort' key is a string that cannot be coerced to a float (e.g. 'highx'). SGLang accepts numeric strings for effort, matching the lax union of the top-level reasoning_effort field, but anything non-numeric fails here.","triggerScenarios":"POST /v1/chat/completions with body {\"reasoning\": {\"effort\": \"abc\"}} where 'abc' is not parseable by float().","commonSituations":"Typos in effort strings like 'hi' or 'maximum'; passing model-specific effort labels that only some models (e.g. Inkling/Harmony) recognize; assuming any string label is accepted.","solutions":["Use a numeric string or number, e.g. \"effort\": \"0.7\" or 0.7, or a supported label like 'low'/'medium'/'high' where mapped elsewhere","Remove the effort key to use the server default","Check the reasoning dict shape: {\"reasoning\": {\"effort\": <number|numeric-string>}}"],"exampleFix":"// before\n{\"reasoning\": {\"effort\": \"maximun\"}}\n// after\n{\"reasoning\": {\"effort\": 0.9}}","handlingStrategy":"validation","validationCode":"effort = req.get(\"reasoning\", {}).get(\"effort\")\nif isinstance(effort, str):\n    try:\n        float(effort)\n    except ValueError:\n        raise ValueError(\"effort must be numeric or a numeric string\")","typeGuard":"def is_valid_effort(e) -> bool:\n    return e is None or isinstance(e, (int, float)) or (isinstance(e, str) and _float_ok(e))","tryCatchPattern":"try: client.chat.completions.create(...)\nexcept ValueError as e: if 'invalid reasoning effort' in str(e): fix effort","preventionTips":["Validate reasoning.effort against number|numeric-string before sending","Centralize effort normalization in one client helper"],"tags":["openai-api","reasoning","validation","sglang"],"backgroundTag":"invalid-request-parameter","analyzedSha":"0132848349585cfe6aae51c4941cbae872505f8a","analyzedAt":"2026-08-28T05:10:05.995Z","schemaVersion":2},"datasetVersion":"2026-08-28T06:17:29.519Z"}