Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/crewai/src/crewai/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@
LiteLLMStreamingChoices = None
get_supported_openai_params = None
ChatCompletionDeltaToolCall = None
ChatCompletionDeltaCustomToolCall = None
Function = None
ModelResponse = None
supports_response_schema = None
Expand All @@ -136,7 +135,7 @@ def _ensure_litellm() -> bool:
global _litellm_loaded, LITELLM_AVAILABLE
global litellm, Choices, LiteLLMDelta, Message, ModelResponseBase
global ModelResponseStream, LiteLLMStreamingChoices, get_supported_openai_params
global ChatCompletionDeltaCustomToolCall, ChatCompletionDeltaToolCall, Function
global ChatCompletionDeltaToolCall, Function

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compat test still expects dropped name

Medium Severity

Dropping the module-level ChatCompletionDeltaCustomToolCall binding and its global rebind means crewai.llm no longer exposes that attribute. test_litellm_import_compat.py still monkeypatches and asserts it, so that test raises AttributeError instead of covering older LiteLLM imports.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7d44c9f. Configure here.

global ModelResponse, supports_response_schema

if _litellm_loaded:
Expand Down
19 changes: 19 additions & 0 deletions lib/crewai/tests/test_llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,25 @@ def test_litellm_path_preserves_provider_from_model_prefix(model, expected_provi
assert llm.model == model


@requires_litellm_python_311
def test_litellm_fallback_loads_without_custom_tool_call_delta_type(
monkeypatch: pytest.MonkeyPatch,
) -> None:
"""LiteLLM releases before 1.97.0 lack ChatCompletionDeltaCustomToolCall.

The fallback only needs that type for type checking, so it must still load.
"""
import litellm.types.utils

monkeypatch.delattr(litellm.types.utils, "ChatCompletionDeltaCustomToolCall")
monkeypatch.setattr("crewai.llm._litellm_loaded", False)
monkeypatch.setattr("crewai.llm.LITELLM_AVAILABLE", False)

llm = LLM(model="openai/custom-finetune-model", is_litellm=False)

assert llm.is_litellm is True


def test_litellm_keeps_provider_but_formats_multimodal_as_openai_schema():
llm = LLM(model="anthropic/claude-3-5-haiku-20241022", is_litellm=True)
assert llm.provider == "anthropic"
Expand Down
Loading