def test_tools_to_converse_tools_with_tool_required():
    """Test that tool_required=True sets toolChoice to {"any": {}}."""

    def search(query: str) -> str:
        """Search for information about a query."""
        return f"Results for {query}"

    tool = FunctionTool.from_defaults(
        fn=search, name="search_tool", description="A tool for searching information"
    )

    result = tools_to_converse_tools([tool], tool_required=True)

    assert "tools" in result
    assert len(result["tools"]) == 1
    assert result["tools"][0]["toolSpec"]["name"] == "search_tool"
    assert result["toolChoice"] == {"any": {}}
Test that tool_required=True sets toolChoice to {"any": {}}.
llama-index-integrations/llms/llama-index-llms-bedrock-converse/tests/test_bedrock_converse_utils.py