{"record":{"id":"194f81f79348caa6","repo":"BerriAI/litellm","slug":"invalid-tool-choice-for-oci-missing-or-non-string","errorCode":null,"errorMessage":"Invalid tool_choice for OCI: missing or non-string 'type' in {tc!r}","messagePattern":"Invalid tool_choice for OCI: missing or non-string 'type' in (.+?)","errorType":"exception","errorClass":"OCIError","httpStatus":400,"severity":"error","filePath":"litellm/llms/oci/chat/transformation.py","lineNumber":153,"sourceCode":"\n\ndef _normalize_tool_choice(selected_params: dict) -> None:\n    tc: Final = selected_params.get(\"toolChoice\")\n    if tc is None:\n        return\n    if isinstance(tc, str):\n        tc_map: Final = {\n            \"auto\": {\"type\": \"AUTO\"},\n            \"none\": {\"type\": \"NONE\"},\n            \"required\": {\"type\": \"REQUIRED\"},\n            \"any\": {\"type\": \"REQUIRED\"},\n        }\n        selected_params[\"toolChoice\"] = tc_map.get(tc.lower(), {\"type\": \"FUNCTION\", \"name\": tc})\n        return\n    if isinstance(tc, dict):\n        raw_type: Final = tc.get(\"type\")\n        if not isinstance(raw_type, str):\n            raise OCIError(\n                status_code=400,\n                message=f\"Invalid tool_choice for OCI: missing or non-string 'type' in {tc!r}\",\n            )\n        upper: Final = raw_type.upper()\n        if upper == \"FUNCTION\":\n            fn: Final = tc.get(\"function\")\n            name: Final = fn.get(\"name\") if isinstance(fn, dict) else tc.get(\"name\")\n            if not (isinstance(name, str) and name):\n                raise OCIError(\n                    status_code=400,\n                    message=\"Invalid tool_choice for OCI: 'FUNCTION' type requires a non-empty function name\",\n                )\n            selected_params[\"toolChoice\"] = {\"type\": \"FUNCTION\", \"name\": name}\n        elif upper in {\"AUTO\", \"NONE\", \"REQUIRED\"}:\n            selected_params[\"toolChoice\"] = {\"type\": upper}\n        else:\n            raise OCIError(\n                status_code=400,","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/BerriAI/litellm/blob/6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d/litellm/llms/oci/chat/transformation.py#L135-L171","documentation":"Error \"Invalid tool_choice for OCI: missing or non-string 'type' in {tc!r}\" thrown in BerriAI/litellm.","triggerScenarios":"Thrown at litellm/llms/oci/chat/transformation.py:153 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass tool_choice with a string 'type' for OCI."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"6c2dcb801bf2b75c18f1bb24140e7cf57465cc4d","analyzedAt":"2026-08-15T07:12:03.035Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}