diff --git a/lib/crewai/src/crewai/agent.py b/lib/crewai/src/crewai/agent.py index 9f5e754f6..dc96e1bf3 100644 --- a/lib/crewai/src/crewai/agent.py +++ b/lib/crewai/src/crewai/agent.py @@ -702,10 +702,7 @@ class Agent(BaseAgent): current_date = datetime.now().strftime(self.date_format) task.description += f"\n\nCurrent Date: {current_date}" except Exception as e: - if hasattr(self, "_logger"): - self._logger.log("warning", f"Failed to inject date: {e!s}") - else: - print(f"Warning: Failed to inject date: {e!s}") + self._logger.log("warning", f"Failed to inject date: {e!s}") def _validate_docker_installation(self) -> None: """Check if Docker is installed and running.""" diff --git a/lib/crewai/src/crewai/agents/agent_builder/base_agent_executor_mixin.py b/lib/crewai/src/crewai/agents/agent_builder/base_agent_executor_mixin.py index 60de79dcc..bed49da67 100644 --- a/lib/crewai/src/crewai/agents/agent_builder/base_agent_executor_mixin.py +++ b/lib/crewai/src/crewai/agents/agent_builder/base_agent_executor_mixin.py @@ -45,7 +45,7 @@ class CrewAgentExecutorMixin: }, ) except Exception as e: - print(f"Failed to add to short term memory: {e}") + self.agent._logger.log("error", f"Failed to add to short term memory: {e}") def _create_external_memory(self, output) -> None: """Create and save a external-term memory item if conditions are met.""" @@ -65,7 +65,7 @@ class CrewAgentExecutorMixin: }, ) except Exception as e: - print(f"Failed to add to external memory: {e}") + self.agent._logger.log("error", f"Failed to add to external memory: {e}") def _create_long_term_memory(self, output) -> None: """Create and save long-term and entity memory items based on evaluation.""" @@ -110,9 +110,9 @@ class CrewAgentExecutorMixin: if entity_memories: self.crew._entity_memory.save(entity_memories) except AttributeError as e: - print(f"Missing attributes for long term memory: {e}") + self.agent._logger.log("error", f"Missing attributes for long term memory: {e}") except Exception as e: - print(f"Failed to add to long term memory: {e}") + self.agent._logger.log("error", f"Failed to add to long term memory: {e}") elif ( self.crew and self.crew._long_term_memory