Remove verbose logging from HierarchicalSwarm

Removed verbose logging statements throughout the HierarchicalSwarm class to streamline the initialization and execution processes.
pull/1231/head
CI-DEV 1 month ago committed by GitHub
parent dfe13551bf
commit 0edd364545
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -828,11 +828,6 @@ class HierarchicalSwarm:
Raises: Raises:
ValueError: If the swarm configuration is invalid. ValueError: If the swarm configuration is invalid.
""" """
# Initialize logger only if verbose is enabled
if self.verbose:
logger.info(
f"[INIT] Initializing HierarchicalSwarm: {self.name}"
)
self.conversation = Conversation(time_enabled=False) self.conversation = Conversation(time_enabled=False)
@ -854,11 +849,6 @@ class HierarchicalSwarm:
# Force refresh to ensure agents are displayed # Force refresh to ensure agents are displayed
self.dashboard.force_refresh() self.dashboard.force_refresh()
if self.verbose:
logger.success(
f"[SUCCESS] HierarchicalSwarm: {self.name} initialized successfully."
)
if self.multi_agent_prompt_improvements: if self.multi_agent_prompt_improvements:
self.prepare_worker_agents() self.prepare_worker_agents()
@ -890,10 +880,6 @@ class HierarchicalSwarm:
Raises: Raises:
Exception: If adding context fails due to agent configuration issues. Exception: If adding context fails due to agent configuration issues.
""" """
try:
if self.verbose:
logger.info("[INFO] Adding agent context to director")
list_all_agents( list_all_agents(
agents=self.agents, agents=self.agents,
conversation=self.conversation, conversation=self.conversation,
@ -901,10 +887,6 @@ class HierarchicalSwarm:
add_collaboration_prompt=self.add_collaboration_prompt, add_collaboration_prompt=self.add_collaboration_prompt,
) )
if self.verbose:
logger.success(
"[SUCCESS] Agent context added to director successfully"
)
except Exception as e: except Exception as e:
error_msg = ( error_msg = (
@ -928,14 +910,9 @@ class HierarchicalSwarm:
Exception: If director setup fails due to configuration issues. Exception: If director setup fails due to configuration issues.
""" """
try: try:
if self.verbose:
logger.info("[SETUP] Setting up director agent")
schema = BaseTool().base_model_to_dict(SwarmSpec) schema = BaseTool().base_model_to_dict(SwarmSpec)
if self.verbose:
logger.debug(f"[SCHEMA] Director schema: {schema}")
return Agent( return Agent(
agent_name=self.director_name, agent_name=self.director_name,
agent_description="A director agent that can create a plan and distribute orders to agents", agent_description="A director agent that can create a plan and distribute orders to agents",
@ -964,10 +941,6 @@ class HierarchicalSwarm:
ValueError: If the swarm configuration is invalid. ValueError: If the swarm configuration is invalid.
""" """
try: try:
if self.verbose:
logger.info(
f"Hiearchical Swarm: {self.name} Reliability checks in progress..."
)
if not self.agents or len(self.agents) == 0: if not self.agents or len(self.agents) == 0:
raise ValueError( raise ValueError(
@ -982,11 +955,6 @@ class HierarchicalSwarm:
if self.director is None: if self.director is None:
self.director = self.setup_director() self.director = self.setup_director()
if self.verbose:
logger.success(
f"Hiearchical Swarm: {self.name} Reliability checks passed..."
)
except Exception as e: except Exception as e:
error_msg = f"[ERROR] Failed to setup director: {str(e)}\n[TRACE] Traceback: {traceback.format_exc()}\n[BUG] If this issue persists, please report it at: https://github.com/kyegomez/swarms/issues" error_msg = f"[ERROR] Failed to setup director: {str(e)}\n[TRACE] Traceback: {traceback.format_exc()}\n[BUG] If this issue persists, please report it at: https://github.com/kyegomez/swarms/issues"
logger.error(error_msg) logger.error(error_msg)
@ -1019,10 +987,6 @@ class HierarchicalSwarm:
Exception: If director execution fails. Exception: If director execution fails.
""" """
try: try:
if self.verbose:
logger.info(
f"[RUN] Running director with task: {task}"
)
if self.planning_director_agent is not None: if self.planning_director_agent is not None:
plan = self.planning_director_agent.run( plan = self.planning_director_agent.run(
@ -1070,10 +1034,6 @@ class HierarchicalSwarm:
role="Director", content=function_call role="Director", content=function_call
) )
if self.verbose:
logger.success(
"[SUCCESS] Director execution completed"
)
logger.debug( logger.debug(
f"[OUTPUT] Director output type: {type(function_call)}" f"[OUTPUT] Director output type: {type(function_call)}"
) )
@ -1120,10 +1080,6 @@ class HierarchicalSwarm:
Exception: If step execution fails. Exception: If step execution fails.
""" """
try: try:
if self.verbose:
logger.info(
f"[STEP] Executing single step for task: {task}"
)
# Update dashboard for director execution # Update dashboard for director execution
if self.interactive and self.dashboard: if self.interactive and self.dashboard:
@ -1134,10 +1090,6 @@ class HierarchicalSwarm:
# Parse the orders # Parse the orders
plan, orders = self.parse_orders(output) plan, orders = self.parse_orders(output)
if self.verbose:
logger.info(
f"[PARSE] Parsed plan and {len(orders)} orders"
)
# Update dashboard with plan and orders information # Update dashboard with plan and orders information
if self.interactive and self.dashboard: if self.interactive and self.dashboard:
@ -1157,20 +1109,12 @@ class HierarchicalSwarm:
outputs = self.execute_orders( outputs = self.execute_orders(
orders, streaming_callback=streaming_callback orders, streaming_callback=streaming_callback
) )
if self.verbose:
logger.info(f"[EXEC] Executed {len(outputs)} orders")
if self.director_feedback_on is True: if self.director_feedback_on is True:
feedback = self.feedback_director(outputs) feedback = self.feedback_director(outputs)
else: else:
feedback = outputs feedback = outputs
if self.verbose:
logger.success(
"[SUCCESS] Step completed successfully"
)
return feedback return feedback
except Exception as e: except Exception as e:
@ -1227,19 +1171,8 @@ class HierarchicalSwarm:
self.dashboard.start(self.max_loops) self.dashboard.start(self.max_loops)
self.dashboard.update_director_status("ACTIVE") self.dashboard.update_director_status("ACTIVE")
if self.verbose:
logger.info(
f"[START] Starting hierarchical swarm run: {self.name}"
)
logger.info(
f"[CONFIG] Configuration - Max loops: {self.max_loops}"
)
while current_loop < self.max_loops: while current_loop < self.max_loops:
if self.verbose:
logger.info(
f"[LOOP] Loop {current_loop + 1}/{self.max_loops} - Processing task"
)
# Update dashboard loop counter # Update dashboard loop counter
if self.interactive and self.dashboard: if self.interactive and self.dashboard:
@ -1269,12 +1202,7 @@ class HierarchicalSwarm:
*args, *args,
**kwargs, **kwargs,
) )
if self.verbose:
logger.success(
f"[SUCCESS] Loop {current_loop + 1} completed successfully"
)
except Exception as e: except Exception as e:
error_msg = f"[ERROR] Failed to setup director: {str(e)}\n[TRACE] Traceback: {traceback.format_exc()}\n[BUG] If this issue persists, please report it at: https://github.com/kyegomez/swarms/issues" error_msg = f"[ERROR] Failed to setup director: {str(e)}\n[TRACE] Traceback: {traceback.format_exc()}\n[BUG] If this issue persists, please report it at: https://github.com/kyegomez/swarms/issues"
logger.error(error_msg) logger.error(error_msg)
@ -1291,14 +1219,7 @@ class HierarchicalSwarm:
if self.interactive and self.dashboard: if self.interactive and self.dashboard:
self.dashboard.update_director_status("COMPLETED") self.dashboard.update_director_status("COMPLETED")
self.dashboard.stop() self.dashboard.stop()
if self.verbose:
logger.success(
f"[COMPLETE] Hierarchical swarm run completed: {self.name}"
)
logger.info(
f"[STATS] Total loops executed: {current_loop}"
)
return history_output_formatter( return history_output_formatter(
conversation=self.conversation, type=self.output_type conversation=self.conversation, type=self.output_type
@ -1350,8 +1271,6 @@ class HierarchicalSwarm:
Exception: If feedback generation fails. Exception: If feedback generation fails.
""" """
try: try:
if self.verbose:
logger.info("[FEEDBACK] Generating director feedback")
task = f"History: {self.conversation.get_str()} \n\n" task = f"History: {self.conversation.get_str()} \n\n"
@ -1376,11 +1295,6 @@ class HierarchicalSwarm:
role=self.director.agent_name, content=output role=self.director.agent_name, content=output
) )
if self.verbose:
logger.success(
"[SUCCESS] Director feedback generated successfully"
)
return output return output
except Exception as e: except Exception as e:
@ -1421,9 +1335,6 @@ class HierarchicalSwarm:
Exception: If agent execution fails. Exception: If agent execution fails.
""" """
try: try:
if self.verbose:
logger.info(f"[CALL] Calling agent: {agent_name}")
# Find agent by name # Find agent by name
agent = None agent = None
for a in self.agents: for a in self.agents:
@ -1488,12 +1399,6 @@ class HierarchicalSwarm:
**kwargs, **kwargs,
) )
self.conversation.add(role=agent_name, content=output) self.conversation.add(role=agent_name, content=output)
if self.verbose:
logger.success(
f"[SUCCESS] Agent {agent_name} completed task successfully"
)
return output return output
except Exception as e: except Exception as e:
@ -1526,9 +1431,6 @@ class HierarchicalSwarm:
Exception: If parsing fails due to other errors. Exception: If parsing fails due to other errors.
""" """
try: try:
if self.verbose:
logger.info("[PARSE] Parsing director orders")
logger.debug(f"[TYPE] Output type: {type(output)}")
import json import json
@ -1570,11 +1472,6 @@ class HierarchicalSwarm:
] ]
] ]
if self.verbose:
logger.success(
f"[SUCCESS] Successfully parsed plan and {len(orders)} orders"
)
return plan, orders return plan, orders
except ( except (
json.JSONDecodeError json.JSONDecodeError
@ -1604,11 +1501,6 @@ class HierarchicalSwarm:
] ]
] ]
if self.verbose:
logger.success(
f"[SUCCESS] Successfully parsed plan and {len(orders)} orders"
)
return plan, orders return plan, orders
except ( except (
json.JSONDecodeError json.JSONDecodeError
@ -1631,11 +1523,6 @@ class HierarchicalSwarm:
for order in output["orders"] for order in output["orders"]
] ]
if self.verbose:
logger.success(
f"[SUCCESS] Successfully parsed plan and {len(orders)} orders"
)
return plan, orders return plan, orders
else: else:
raise ValueError( raise ValueError(
@ -1678,9 +1565,6 @@ class HierarchicalSwarm:
Exception: If order execution fails. Exception: If order execution fails.
""" """
try: try:
if self.verbose:
logger.info(f"[EXEC] Executing {len(orders)} orders")
outputs = [] outputs = []
for i, order in enumerate(orders): for i, order in enumerate(orders):
if self.verbose: if self.verbose:
@ -1717,11 +1601,6 @@ class HierarchicalSwarm:
outputs.append(output) outputs.append(output)
if self.verbose:
logger.success(
f"[SUCCESS] All {len(orders)} orders executed successfully"
)
return outputs return outputs
except Exception as e: except Exception as e:
@ -1761,14 +1640,6 @@ class HierarchicalSwarm:
Exception: If batched execution fails. Exception: If batched execution fails.
""" """
try: try:
if self.verbose:
logger.info(
f"[START] Starting batched hierarchical swarm run: {self.name}"
)
logger.info(
f"[CONFIG] Configuration - Max loops: {self.max_loops}"
)
# Initialize a list to store the results # Initialize a list to store the results
results = [] results = []
@ -1783,20 +1654,7 @@ class HierarchicalSwarm:
) )
results.append(result) results.append(result)
if self.verbose:
logger.success(
f"[COMPLETE] Batched hierarchical swarm run completed: {self.name}"
)
logger.info(
f"[STATS] Total tasks processed: {len(tasks)}"
)
return results return results
except Exception as e: except Exception as e:
error_msg = f"[ERROR] Batched hierarchical swarm run failed: {str(e)}" error_msg = f"[ERROR] Batched hierarchical swarm run failed: {str(e)}"
if self.verbose:
logger.error(error_msg)
logger.error(
f"[TRACE] Traceback: {traceback.format_exc()}"
)

Loading…
Cancel
Save