BerriAI/litellm · error · ValueError

Incompatible tool choice param submitted

Error message

Incompatible tool choice param submitted - {tool_choice}

What it means

Error "Incompatible tool choice param submitted - {tool_choice}" thrown in BerriAI/litellm.

Solutions

  1. Use a tool_choice value compatible with Anthropic ('auto', 'any', 'none', or {'type':'tool','name':...}).
  2. Remove tool_choice or set drop_params=True to drop it.

When it happens

Trigger: Thrown at litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py:713 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of BerriAI/litellm@77b7c6c40c (2026-08-18). Data as JSON: /api/errors/8d004f25f015cfc1. Report an issue: GitHub.

Appendix: source

Thrown at litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py:713

        return reasoning_effort

    def translate_anthropic_tool_choice_to_openai(
        self, tool_choice: AnthropicMessagesToolChoice
    ) -> ChatCompletionToolChoiceValues:
        if tool_choice["type"] == "any":
            return "required"
        elif tool_choice["type"] == "auto":
            return "auto"
        elif tool_choice["type"] == "tool":
            # Truncate tool name if it exceeds OpenAI's 64-char limit
            original_name: Final = tool_choice.get("name", "")
            truncated_name: Final = truncate_tool_name(original_name)
            tc_function_param: Final = ChatCompletionToolChoiceFunctionParam(name=truncated_name)
            return ChatCompletionToolChoiceObjectParam(type="function", function=tc_function_param)
        elif tool_choice["type"] == "none":
            return "none"
        else:
            raise ValueError(f"Incompatible tool choice param submitted - {tool_choice}")

    def translate_anthropic_tools_to_openai(
        self, tools: list[AllAnthropicToolsValues], model: str | None = None
    ) -> tuple[list[ChatCompletionToolParam], dict[str, str]]:
        """
        Translate Anthropic tools to OpenAI format.

        Returns:
            Tuple of (translated_tools, tool_name_mapping)
            - tool_name_mapping maps truncated names back to original names
              for tools that exceeded OpenAI's 64-char limit
        """
        new_tools: Final[list[ChatCompletionToolParam]] = []
        tool_name_mapping: Final[dict[str, str]] = {}
        # "type" is the Anthropic tool type (e.g. "custom"); it must not be
        # merged into the OpenAI function `parameters` schema below, or it
        # overwrites the real parameters.type ("object") and the provider
        # rejects the request. See #30557.

View on GitHub (pinned to 77b7c6c40c)