Failed to convert text into a pydantic model in latest package when only memory=True

I am struggling with exactly same error posted here: Failed to convert text into a Pydantic model due to the following error: litellm.APIConnectionError: 'name'.

Actually, it didn’t raise the exact reason of error like ‘LiteLLM.Info: If you need to debug this error, use `litellm.set_verbose=True’, so I just debugged manually for four hours and found the reason.

Via Ollama docker, I am using

ollama_model = LLM(
    base_url='http://ollama:11434'
    api_key='ollama',
    model="ollama/deepseek-r1:14b"
)

When I set memory=False for Crew, it perfectly works.

crew = Crew(
  agents=[support_agent, support_quality_assurance_agent],
  tasks=[inquiry_resolution, quality_assurance_review],
  verbose=True
)

The problem occurs when only I set memory=True (and then kickoff):

crew = Crew(
  agents=[support_agent, support_quality_assurance_agent],
  tasks=[inquiry_resolution, quality_assurance_review],
  verbose=True,
  memory=True, 
  embedder={ "provider": "ollama", "config": {"model": 'deepseek-r1:14b', "url":"http://ollama:11434/api/embeddings"} }
)

As the image below, you can observe that format of function_call in some cases (as I guess, dealing with memory) is different from that in normal case. That’s why the function_call causes the error that says ‘we don’t have key ‘name’!’ How can I resolve this bug??

Temporary solution

if request_data.get("format", "") == "json":
            function_call = json.loads(response_json["response"])
            if function_call.get('name') is None:
                function_call = {'name': list(function_call.keys())[0], 'arguments': function_call[list(function_call.keys())[0]]}