def test_tool_required_compatibility_without_support(
    person_tool: FunctionTool, person_tool_selection: ToolSelection
) -> None:
    """Test that tool_required parameter is not passed to LLMs that don't support it."""
    llm = MockFunctionCallingLLMWithoutToolRequired([person_tool_selection])

    # Mock the _prepare_chat_with_tools method to capture what arguments it receives
    with patch.object(
        llm, "_prepare_chat_with_tools", wraps=llm._prepare_chat_with_tools
    ) as mock_prepare:
        llm.chat_with_tools(tools=[person_tool], tool_required=True)

        # Verify that tool_required was NOT passed to _prepare_chat_with_tools
        args, kwargs = mock_prepare.call_args
        assert "tool_required" not in kwargs
Test that tool_required parameter is not passed to LLMs that don't support it.
llama-index-core/tests/llms/test_function_calling.py