Skip to content

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.

Add missing @functools.wraps when wrapping functions and preserve wrapped class name in @CrewBase. (#1560)

Piotr Mardzielc4f7eaf2599c
diff --git a/src/crewai/project/annotations.py b/src/crewai/project/annotations.py
index be4710b2b..bf0051c4d 100644
--- a/src/crewai/project/annotations.py
+++ b/src/crewai/project/annotations.py
@@ -66,6 +66,8 @@ def cache_handler(func):
def crew(func) -> Callable[..., Crew]:
+
+ @wraps(func)
def wrapper(self, *args, **kwargs) -> Crew:
instantiated_tasks = []
instantiated_agents = []
diff --git a/src/crewai/project/crew_base.py b/src/crewai/project/crew_base.py
index e93452a6e..0b43882f2 100644
--- a/src/crewai/project/crew_base.py
+++ b/src/crewai/project/crew_base.py
@@ -213,4 +213,8 @@ def CrewBase(cls: T) -> T:
callback_functions[callback]() for callback in callbacks
]
+ # Include base class (qual)name in the wrapper class (qual)name.
+ WrappedClass.__name__ = CrewBase.__name__ + "(" + cls.__name__ + ")"
+ WrappedClass.__qualname__ = CrewBase.__qualname__ + "(" + cls.__name__ + ")"
+
return cast(T, WrappedClass)
diff --git a/src/crewai/project/utils.py b/src/crewai/project/utils.py
index be3f757d9..2e95c755d 100644
--- a/src/crewai/project/utils.py
+++ b/src/crewai/project/utils.py
@@ -1,11 +1,13 @@
+from functools import wraps
+
def memoize(func):
cache = {}
+ @wraps(func)
def memoized_func(*args, **kwargs):
key = (args, tuple(kwargs.items()))
if key not in cache:
cache[key] = func(*args, **kwargs)
return cache[key]
- memoized_func.__dict__.update(func.__dict__)
return memoized_func