From 8e2a529d949f9ddcc77600c05f066db27b20ee2e Mon Sep 17 00:00:00 2001 From: Greyson LaLonde Date: Tue, 14 Apr 2026 00:51:11 +0800 Subject: [PATCH] chore: add deprecation decorator to LiteAgent --- lib/crewai/src/crewai/lite_agent.py | 22 ++++++---------------- lib/crewai/tests/agents/test_lite_agent.py | 2 +- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/lib/crewai/src/crewai/lite_agent.py b/lib/crewai/src/crewai/lite_agent.py index 07813b60f..5ddddc89e 100644 --- a/lib/crewai/src/crewai/lite_agent.py +++ b/lib/crewai/src/crewai/lite_agent.py @@ -16,7 +16,6 @@ from typing import ( get_origin, ) import uuid -import warnings from pydantic import ( UUID4, @@ -26,7 +25,7 @@ from pydantic import ( field_validator, model_validator, ) -from typing_extensions import Self +from typing_extensions import Self, deprecated if TYPE_CHECKING: @@ -173,9 +172,12 @@ def _kickoff_with_a2a_support( ) +@deprecated( + "LiteAgent is deprecated and will be removed in v2.0.0.", + category=FutureWarning, +) class LiteAgent(FlowTrackable, BaseModel): - """ - A lightweight agent that can process messages and use tools. + """A lightweight agent that can process messages and use tools. .. deprecated:: LiteAgent is deprecated and will be removed in a future version. @@ -278,18 +280,6 @@ class LiteAgent(FlowTrackable, BaseModel): ) _memory: Any = PrivateAttr(default=None) - @model_validator(mode="after") - def emit_deprecation_warning(self) -> Self: - """Emit deprecation warning for LiteAgent usage.""" - warnings.warn( - "LiteAgent is deprecated and will be removed in a future version. " - "Use Agent().kickoff(messages) instead, which provides the same " - "functionality with additional features like memory and knowledge support.", - DeprecationWarning, - stacklevel=2, - ) - return self - @model_validator(mode="after") def setup_llm(self) -> Self: """Set up the LLM and other components after initialization.""" diff --git a/lib/crewai/tests/agents/test_lite_agent.py b/lib/crewai/tests/agents/test_lite_agent.py index b42e2c1ec..37d115228 100644 --- a/lib/crewai/tests/agents/test_lite_agent.py +++ b/lib/crewai/tests/agents/test_lite_agent.py @@ -1051,7 +1051,7 @@ def test_lite_agent_verbose_false_suppresses_printer_output(): successful_requests=1, ) - with pytest.warns(DeprecationWarning): + with pytest.warns(FutureWarning): agent = LiteAgent( role="Test Agent", goal="Test goal",