The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
fix(litellm): function-calling check blocks all calls on non-tool models (#5536)
Hrushikesh Yadav09a9e34382b8
diff --git a/mem0/llms/litellm.py b/mem0/llms/litellm.pyindex 607ff5622..e28d0a198 100644--- a/mem0/llms/litellm.py+++ b/mem0/llms/litellm.py@@ -67,7 +67,7 @@ class LiteLLM(LLMBase):Returns:str: The generated response."""- if not litellm.supports_function_calling(self.config.model):+ if tools and not litellm.supports_function_calling(self.config.model):raise ValueError(f"Model '{self.config.model}' in litellm does not support function calling.")params = {diff --git a/tests/llms/test_litellm.py b/tests/llms/test_litellm.pyindex e1d0eaf2a..4516a090c 100644--- a/tests/llms/test_litellm.py+++ b/tests/llms/test_litellm.py@@ -19,8 +19,26 @@ def test_generate_response_with_unsupported_model(mock_litellm):mock_litellm.supports_function_calling.return_value = False+ tools = [{"type": "function", "function": {"name": "test", "parameters": {}}}]+with pytest.raises(ValueError, match="Model 'unsupported-model' in litellm does not support function calling."):- llm.generate_response(messages)+ llm.generate_response(messages, tools=tools)+++def test_generate_response_with_unsupported_model_no_tools(mock_litellm):+ config = BaseLlmConfig(model="unsupported-model", temperature=0.7, max_tokens=100, top_p=1)+ llm = litellm.LiteLLM(config)+ messages = [{"role": "user", "content": "Hello"}]++ mock_response = Mock()+ mock_response.choices = [Mock(message=Mock(content="hi"))]+ mock_litellm.completion.return_value = mock_response+ mock_litellm.supports_function_calling.return_value = False++ response = llm.generate_response(messages)++ assert response == "hi"+ mock_litellm.supports_function_calling.assert_not_called()def test_generate_response_without_tools(mock_litellm):