BerriAI/litellm · error · OCIError

Invalid tool_choice for OCI: missing or non-string 'type' in

Error message

Invalid tool_choice for OCI: missing or non-string 'type' in {tc!r}

What it means

Error "Invalid tool_choice for OCI: missing or non-string 'type' in {tc!r}" thrown in BerriAI/litellm.

Source

Thrown at litellm/llms/oci/chat/transformation.py:153


def _normalize_tool_choice(selected_params: dict) -> None:
    tc: Final = selected_params.get("toolChoice")
    if tc is None:
        return
    if isinstance(tc, str):
        tc_map: Final = {
            "auto": {"type": "AUTO"},
            "none": {"type": "NONE"},
            "required": {"type": "REQUIRED"},
            "any": {"type": "REQUIRED"},
        }
        selected_params["toolChoice"] = tc_map.get(tc.lower(), {"type": "FUNCTION", "name": tc})
        return
    if isinstance(tc, dict):
        raw_type: Final = tc.get("type")
        if not isinstance(raw_type, str):
            raise OCIError(
                status_code=400,
                message=f"Invalid tool_choice for OCI: missing or non-string 'type' in {tc!r}",
            )
        upper: Final = raw_type.upper()
        if upper == "FUNCTION":
            fn: Final = tc.get("function")
            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,

View on GitHub (pinned to 6c2dcb801b)

Solutions

  1. Pass tool_choice with a string 'type' for OCI.

When it happens

Trigger: Thrown at litellm/llms/oci/chat/transformation.py:153 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/194f81f79348caa6. Report an issue: GitHub.