def test_prepare_chat_with_tools_default_behavior():
    """Test default behavior when tool_required is not specified (should default to False/auto)."""
    llm = OpenAI(api_key="test-key")

    result = llm._prepare_chat_with_tools(
        tools=[search_tool], user_msg="Search for Python tutorials"
    )

    assert "messages" in result
    assert "tools" in result
    assert "tool_choice" in result
    assert len(result["tools"]) == 1
    assert result["tools"][0]["function"]["name"] == "search_tool"
    # Should default to "auto" when tool_required=False (default)
    assert result["tool_choice"] == "auto"
Test default behavior when tool_required is not specified (should default to False/auto).
llama-index-integrations/llms/llama-index-llms-openai/tests/test_llms_openai.py