BerriAI/litellm · error · OCIError
Invalid tool_choice for OCI: expected str or dict, got {type
Error message
Invalid tool_choice for OCI: expected str or dict, got {type(tc).__name__} What it means
Error "Invalid tool_choice for OCI: expected str or dict, got {type(tc).__name__}" thrown in BerriAI/litellm.
Source
Thrown at litellm/llms/oci/chat/transformation.py:178
name: Final = fn.get("name") if isinstance(fn, dict) else tc.get("name")
if not (isinstance(name, str) and name):
raise OCIError(
status_code=400,
message="Invalid tool_choice for OCI: 'FUNCTION' type requires a non-empty function name",
)
selected_params["toolChoice"] = {"type": "FUNCTION", "name": name}
elif upper in {"AUTO", "NONE", "REQUIRED"}:
selected_params["toolChoice"] = {"type": upper}
else:
raise OCIError(
status_code=400,
message=(
f"Invalid tool_choice for OCI: unsupported type {raw_type!r}; "
"expected one of 'FUNCTION', 'AUTO', 'NONE', 'REQUIRED'"
),
)
return
raise OCIError(
status_code=400,
message=(f"Invalid tool_choice for OCI: expected str or dict, got {type(tc).__name__}"),
)
def _normalize_response_format(selected_params: dict, vendor: OCIVendors) -> None:
rf: Final = selected_params.get("responseFormat")
if not isinstance(rf, dict) or "type" not in rf:
return
rf_type: Final = str(rf["type"]).lower()
raw_schema: Final = rf.get("json_schema")
json_schema: Final = raw_schema if isinstance(raw_schema, dict) else None
if rf_type == "text":
selected_params["responseFormat"] = {"type": "TEXT"}
return
View on GitHub (pinned to 6c2dcb801b)
Solutions
- Pass tool_choice as a string or dict.
When it happens
Trigger: Thrown at litellm/llms/oci/chat/transformation.py:178 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BerriAI/litellm@6c2dcb801b (2026-08-15).
Data as JSON: /api/errors/37151c263a09ac3c.
Report an issue: GitHub.