mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-05-06 09:42:39 +00:00
refactor: remove debug print statements from Crew class and clean up commented code in BaseAgentTool
This commit is contained in:
@@ -491,8 +491,6 @@ class Crew(BaseModel):
|
||||
"""Trains the crew for a given number of iterations."""
|
||||
train_crew = self.copy()
|
||||
train_crew._setup_for_training(filename)
|
||||
|
||||
print("DEBUG N ITERATIONS: ", n_iterations)
|
||||
|
||||
for n_iteration in range(n_iterations):
|
||||
train_crew._train_iteration = n_iteration
|
||||
@@ -520,7 +518,6 @@ class Crew(BaseModel):
|
||||
inputs = before_callback(inputs)
|
||||
|
||||
"""Starts the crew to work on its assigned tasks."""
|
||||
print("DEBUG: KICKOFF FOR CREW CALLED")
|
||||
self._execution_span = self._telemetry.crew_execution_span(self, inputs)
|
||||
self._task_output_handler.reset()
|
||||
self._logging_color = "bold_purple"
|
||||
@@ -710,7 +707,6 @@ class Crew(BaseModel):
|
||||
Returns:
|
||||
CrewOutput: Final output of the crew
|
||||
"""
|
||||
print("DEBUG: EXECUTE TASKS CALLED")
|
||||
task_outputs: List[TaskOutput] = []
|
||||
futures: List[Tuple[Task, Future[TaskOutput], int]] = []
|
||||
last_sync_output: Optional[TaskOutput] = None
|
||||
|
||||
@@ -95,83 +95,4 @@ class BaseAgentTool(BaseTool):
|
||||
return self.i18n.errors("agent_tool_execution_error").format(
|
||||
agent_role=sanitized_name,
|
||||
error=str(e)
|
||||
)
|
||||
|
||||
# def _execute(
|
||||
# self,
|
||||
# agent_name: Optional[str],
|
||||
# task: str,
|
||||
# context: Optional[str] = None
|
||||
# ) -> str:
|
||||
# """
|
||||
# Execute delegation to an agent with case-insensitive and whitespace-tolerant matching.
|
||||
|
||||
# Args:
|
||||
# agent_name: Name/role of the agent to delegate to (case-insensitive)
|
||||
# task: The specific question or task to delegate
|
||||
# context: Optional additional context for the task execution
|
||||
|
||||
# Returns:
|
||||
# str: The execution result from the delegated agent or an error message
|
||||
# if the agent cannot be found
|
||||
# """
|
||||
# try:
|
||||
# print("\n=== Delegating Work ===")
|
||||
|
||||
# if agent_name is None:
|
||||
# agent_name = ""
|
||||
# logger.debug("No agent name provided, using empty string")
|
||||
|
||||
# # It is important to remove the quotes from the agent name.
|
||||
# # The reason we have to do this is because less-powerful LLM's
|
||||
# # have difficulty producing valid JSON.
|
||||
# # As a result, we end up with invalid JSON that is truncated like this:
|
||||
# # {"task": "....", "coworker": "....
|
||||
# # when it should look like this:
|
||||
# # {"task": "....", "coworker": "...."}
|
||||
# sanitized_name = self.sanitize_agent_name(agent_name)
|
||||
# logger.debug(f"Sanitized agent name from '{agent_name}' to '{sanitized_name}'")
|
||||
|
||||
# available_agents = [agent.role for agent in self.agents]
|
||||
# logger.debug(f"Available agents: {available_agents}")
|
||||
|
||||
# agent = [ # type: ignore # Incompatible types in assignment (expression has type "list[BaseAgent]", variable has type "str | None")
|
||||
# available_agent
|
||||
# for available_agent in self.agents
|
||||
# if self.sanitize_agent_name(available_agent.role) == sanitized_name
|
||||
# ]
|
||||
# logger.debug(f"Found {len(agent)} matching agents for role '{sanitized_name}'")
|
||||
# except (AttributeError, ValueError) as e:
|
||||
# # Handle specific exceptions that might occur during role name processing
|
||||
# return self.i18n.errors("agent_tool_unexisting_coworker").format(
|
||||
# coworkers="\n".join(
|
||||
# [f"- {self.sanitize_agent_name(agent.role)}" for agent in self.agents]
|
||||
# ),
|
||||
# error=str(e)
|
||||
# )
|
||||
|
||||
# if not agent:
|
||||
# # No matching agent found after sanitization
|
||||
# return self.i18n.errors("agent_tool_unexisting_coworker").format(
|
||||
# coworkers="\n".join(
|
||||
# [f"- {self.sanitize_agent_name(agent.role)}" for agent in self.agents]
|
||||
# ),
|
||||
# error=f"No agent found with role '{sanitized_name}'"
|
||||
# )
|
||||
|
||||
# agent = agent[0]
|
||||
# try:
|
||||
# task_with_assigned_agent = Task(
|
||||
# description=task,
|
||||
# agent=agent,
|
||||
# expected_output=agent.i18n.slice("manager_request"),
|
||||
# i18n=agent.i18n,
|
||||
# )
|
||||
# logger.debug(f"Created task for agent '{self.sanitize_agent_name(agent.role)}': {task}")
|
||||
# return agent.execute_task(task_with_assigned_agent, context)
|
||||
# except Exception as e:
|
||||
# # Handle task creation or execution errors
|
||||
# return self.i18n.errors("agent_tool_execution_error").format(
|
||||
# agent_role=self.sanitize_agent_name(agent.role),
|
||||
# error=str(e)
|
||||
# )
|
||||
)
|
||||
Reference in New Issue
Block a user