fix: replace print statements with logger in agent and memory handling

This commit is contained in:
Greyson LaLonde
2025-10-08 17:28:50 -04:00
parent 11f6b34aa3
commit 458f56fb33
2 changed files with 5 additions and 8 deletions

View File

@@ -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."""

View File

@@ -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