2929from crewai .security .security_config import SecurityConfig
3030from crewai .tools .base_tool import BaseTool , Tool
3131from crewai .utilities .config import process_config
32- from crewai .utilities .i18n import I18N
32+ from crewai .utilities .i18n import I18N , get_i18n
3333from crewai .utilities .logger import Logger
3434from crewai .utilities .rpm_controller import RPMController
3535from crewai .utilities .string_utils import interpolate_only
@@ -107,7 +107,7 @@ class BaseAgent(BaseModel, ABC, metaclass=AgentMeta):
107107 Set private attributes.
108108 """
109109
110- __hash__ = object .__hash__ # type: ignore
110+ __hash__ = object .__hash__
111111 _logger : Logger = PrivateAttr (default_factory = lambda : Logger (verbose = False ))
112112 _rpm_controller : RPMController | None = PrivateAttr (default = None )
113113 _request_within_rpm_limit : Any = PrivateAttr (default = None )
@@ -150,7 +150,7 @@ class BaseAgent(BaseModel, ABC, metaclass=AgentMeta):
150150 )
151151 crew : Any = Field (default = None , description = "Crew to which the agent belongs." )
152152 i18n : I18N = Field (
153- default_factory = I18N , description = "Internationalization settings."
153+ default_factory = get_i18n , description = "Internationalization settings."
154154 )
155155 cache_handler : CacheHandler | None = Field (
156156 default = None , description = "An instance of the CacheHandler class."
@@ -180,8 +180,8 @@ class BaseAgent(BaseModel, ABC, metaclass=AgentMeta):
180180 default_factory = SecurityConfig ,
181181 description = "Security configuration for the agent, including fingerprinting." ,
182182 )
183- callbacks : list [Callable ] = Field (
184- default = [] , description = "Callbacks to be used for the agent"
183+ callbacks : list [Callable [[ Any ], Any ] ] = Field (
184+ default_factory = list , description = "Callbacks to be used for the agent"
185185 )
186186 adapted_agent : bool = Field (
187187 default = False , description = "Whether the agent is adapted"
@@ -201,7 +201,7 @@ class BaseAgent(BaseModel, ABC, metaclass=AgentMeta):
201201
202202 @model_validator (mode = "before" )
203203 @classmethod
204- def process_model_config (cls , values ) :
204+ def process_model_config (cls , values : Any ) -> dict [ str , Any ] :
205205 return process_config (values , cls )
206206
207207 @field_validator ("tools" )
@@ -269,7 +269,7 @@ def validate_mcps(cls, mcps: list[str] | None) -> list[str] | None:
269269 return list (set (validated_mcps ))
270270
271271 @model_validator (mode = "after" )
272- def validate_and_set_attributes (self ):
272+ def validate_and_set_attributes (self ) -> Self :
273273 # Validate required fields
274274 for field in ["role" , "goal" , "backstory" ]:
275275 if getattr (self , field ) is None :
@@ -301,7 +301,7 @@ def _deny_user_set_id(cls, v: UUID4 | None) -> None:
301301 )
302302
303303 @model_validator (mode = "after" )
304- def set_private_attrs (self ):
304+ def set_private_attrs (self ) -> Self :
305305 """Set private attributes."""
306306 self ._logger = Logger (verbose = self .verbose )
307307 if self .max_rpm and not self ._rpm_controller :
@@ -313,7 +313,7 @@ def set_private_attrs(self):
313313 return self
314314
315315 @property
316- def key (self ):
316+ def key (self ) -> str :
317317 source = [
318318 self ._original_role or self .role ,
319319 self ._original_goal or self .goal ,
@@ -331,7 +331,7 @@ def execute_task(
331331 pass
332332
333333 @abstractmethod
334- def create_agent_executor (self , tools = None ) -> None :
334+ def create_agent_executor (self , tools : list [ BaseTool ] | None = None ) -> None :
335335 pass
336336
337337 @abstractmethod
@@ -443,5 +443,5 @@ def set_rpm_controller(self, rpm_controller: RPMController) -> None:
443443 self ._rpm_controller = rpm_controller
444444 self .create_agent_executor ()
445445
446- def set_knowledge (self , crew_embedder : EmbedderConfig | None = None ):
446+ def set_knowledge (self , crew_embedder : EmbedderConfig | None = None ) -> None :
447447 pass
0 commit comments