TypeError: expected string or bytes-like object, got 'NoneType' (ProxyCURL custom tool)

Hello!
I am trying to enable my agent to use the “integration with ProxyCURL” tool.
The agent accesses the service, I can see how it finds the person’s mail or not - it doesn’t matter, at the moment when the agent’s chain of actions completes and it should have saved the response to a file and finished its work - the process aborts with the error below.

Traceback (most recent call last):
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agent.py", line 236, in execute_task
    result = self.agent_executor.invoke(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/crew_agent_executor.py", line 93, in invoke
    formatted_answer = self._invoke_loop()
                       ^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/crew_agent_executor.py", line 175, in _invoke_loop
    raise e
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/crew_agent_executor.py", line 131, in _invoke_loop
    formatted_answer = self._format_answer(answer)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/crew_agent_executor.py", line 376, in _format_answer
    return CrewAgentParser(agent=self.agent).parse(answer)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/parser.py", line 73, in parse
    thought = self._extract_thought(text)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/parser.py", line 120, in _extract_thought
    thought_match = re.search(regex, text, re.DOTALL)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/outr_env/lib/python3.11/re/__init__.py", line 176, in search
    return _compile(pattern, flags).search(string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/litellm/llms/anthropic/chat/handler.py", line 565, in completion
    response = client.post(
               ^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/litellm/llms/custom_httpx/http_handler.py", line 386, in post
    raise e
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/litellm/llms/custom_httpx/http_handler.py", line 372, in post
    response.raise_for_status()
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/httpx/_models.py", line 763, in raise_for_status
    raise HTTPStatusError(message, request=request, response=self)
httpx.HTTPStatusError: Server error '529 ' for url 'https://api.anthropic.com/v1/messages'
For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/529

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/litellm/main.py", line 1755, in completion
    response = anthropic_chat_completions.completion(
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/litellm/llms/anthropic/chat/handler.py", line 580, in completion
    raise AnthropicError(
litellm.llms.anthropic.common_utils.AnthropicError: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"}}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agent.py", line 236, in execute_task
    result = self.agent_executor.invoke(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/crew_agent_executor.py", line 93, in invoke
    formatted_answer = self._invoke_loop()
                       ^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/crew_agent_executor.py", line 175, in _invoke_loop
    raise e
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/crew_agent_executor.py", line 115, in _invoke_loop
    answer = self.llm.call(
             ^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/llm.py", line 155, in call
    response = litellm.completion(**params)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/agentops/llms/litellm.py", line 203, in patched_function
    result = self.original_create(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/litellm/utils.py", line 1013, in wrapper
    raise e
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/litellm/utils.py", line 903, in wrapper
    result = original_function(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/litellm/main.py", line 2999, in completion
    raise exception_type(
          ^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 2116, in exception_type
    raise e
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/litellm/litellm_core_utils/exception_mapping_utils.py", line 500, in exception_type
    raise litellm.InternalServerError(
litellm.exceptions.InternalServerError: litellm.InternalServerError: AnthropicException - {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"}}. Handle with `litellm.InternalServerError`.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rzymer/Documents/VSCode/Outreach agent/main.py", line 355, in <module>
    result = crew.kickoff(inputs={
             ^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/crew.py", line 494, in kickoff
    result = self._run_sequential_process()
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/crew.py", line 598, in _run_sequential_process
    return self._execute_tasks(self.tasks)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/crew.py", line 696, in _execute_tasks
    task_output = task.execute_sync(
                  ^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/task.py", line 191, in execute_sync
    return self._execute_core(agent, context, tools)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/task.py", line 247, in _execute_core
    result = agent.execute_task(
             ^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agent.py", line 248, in execute_task
    result = self.execute_task(task, context, tools)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agent.py", line 248, in execute_task
    result = self.execute_task(task, context, tools)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agent.py", line 247, in execute_task
    raise e
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agent.py", line 236, in execute_task
    result = self.agent_executor.invoke(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/crew_agent_executor.py", line 93, in invoke
    formatted_answer = self._invoke_loop()
                       ^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/crew_agent_executor.py", line 175, in _invoke_loop
    raise e
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/crew_agent_executor.py", line 131, in _invoke_loop
    formatted_answer = self._format_answer(answer)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/crew_agent_executor.py", line 376, in _format_answer
    return CrewAgentParser(agent=self.agent).parse(answer)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/parser.py", line 73, in parse
    thought = self._extract_thought(text)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/rzymer/Documents/VSCode/Outreach agent/fresh_env/lib/python3.11/site-packages/crewai/agents/parser.py", line 120, in _extract_thought
    thought_match = re.search(regex, text, re.DOTALL)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/envs/outr_env/lib/python3.11/re/__init__.py", line 176, in search
    return _compile(pattern, flags).search(string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: expected string or bytes-like object, got 'NoneType'

Here is the code of tool:

@tool("Fetch email from LinkedIn profile")
def fetch_email_from_linkedin(linkedin_url: str) -> str:
    """Fetches all available emails associated with a LinkedIn profile."""
    if not linkedin_url or not isinstance(linkedin_url, str):
        return "ProxyCurl: Invalid LinkedIn URL provided"
        
    try:
        # Clean up the LinkedIn URL
        linkedin_url = linkedin_url.strip()
        if not linkedin_url.startswith(('http://', 'https://')):
            linkedin_url = 'https://' + linkedin_url
            
        api_endpoint = 'https://nubela.co/proxycurl/api/v2/linkedin'
        headers = {'Authorization': f'Bearer {proxycurl_api_key}'}
        
        params = {
            'url': linkedin_url,
            'personal_email': 'include',
            'personal_contact_number': 'include',
            'email': 'include'
        }
        
        response = requests.get(
            api_endpoint,
            params=params,
            headers=headers,
            timeout=10
        )
        
        if response.status_code != 200:
            return f"ProxyCurl: API error {response.status_code}"
            
        data = response.json()
        emails = []
        
        # Extract emails from various fields
        if data.get('personal_email'):
            emails.append(data['personal_email'])
        if data.get('work_email'):
            emails.append(data['work_email'])
        if data.get('email'):
            emails.append(data['email'])
            
        # Remove duplicates and empty values
        emails = list(set(filter(None, emails)))
        
        if not emails:
            return "ProxyCurl: No emails found"
            
        return f"ProxyCurl: {', '.join(emails)}"
        
    except requests.exceptions.Timeout:
        return "ProxyCurl: Request timed out"
    except requests.exceptions.RequestException as e:
        return f"ProxyCurl: Network error - {str(e)}"
    except Exception as e:
        return f"ProxyCurl: Error - {str(e)}"

Here is the code of agent:
linkedin_profile_scrape = Task(
description=
“”“Consistently examine the LinkedIn profiles from file_name.md and prepare information and add to the profile file in ‘Data files/Decision makers/FirstName_LastName.md’
“””,
expected_output=
“”"
1. Update the profile file in ‘Data files/Decision makers/FirstName_LastName.md’ .
2. Provide full information about that person.

    Format:
    [Name]
    [LinkedIn link]
    ProxyCURL: [emails_from_proxycurl] if you get "None" - place "No email found"
    ...
    """,
agent=linkedin_profiler,
output_file="Data files/partner_info.md"

)

Please help to fix.