def METHOD_NAME(query: str, agent: Agent, num_results: int = 8) -> str | list[str]:
    """Return the results of a Google search using the official Google API
    Args:
        query (str): The search query.
        num_results (int): The number of results to return.
    Returns:
        str: The results of the search.
    """
    from googleapiclient.discovery import build
    from googleapiclient.errors import HttpError
    try:
        # Get the Google API key and Custom Search Engine ID from the config file
        api_key = agent.config.google_api_key
        custom_search_engine_id = agent.config.google_custom_search_engine_id
        # Initialize the Custom Search API service
        service = build("customsearch", "v1", developerKey=api_key)
        # Send the search query and retrieve the results
        result = (
            service.cse()
            .list(q=query, cx=custom_search_engine_id, num=num_results)
            .execute()
        )
        # Extract the search result items from the response
        search_results = result.get("items", [])
        # Create a list of only the URLs from the search results
        search_results_links = [item["link"] for item in search_results]
    except HttpError as e:
        # Handle errors in the API call
        error_details = json.loads(e.content.decode())
        # Check if the error is related to an invalid or missing API key
        if error_details.get("error", {}).get(
            "code"
        ) == 403 and "invalid API key" in error_details.get("error", {}).get(
            "message", ""
        ):
            raise ConfigurationError(
                "The provided Google API key is invalid or missing."
            )
        raise
    # google_result can be a list or a string depending on the search results
    # Return the list of search result URLs
    return safe_google_results(search_results_links)