Skip to content

Commit 0edd364

Browse files
authored
Remove verbose logging from HierarchicalSwarm
Removed verbose logging statements throughout the HierarchicalSwarm class to streamline the initialization and execution processes.
1 parent dfe1355 commit 0edd364

1 file changed

Lines changed: 3 additions & 145 deletions

File tree

swarms/structs/hiearchical_swarm.py

Lines changed: 3 additions & 145 deletions
Original file line numberDiff line numberDiff line change
@@ -828,11 +828,6 @@ def init_swarm(self):
828828
Raises:
829829
ValueError: If the swarm configuration is invalid.
830830
"""
831-
# Initialize logger only if verbose is enabled
832-
if self.verbose:
833-
logger.info(
834-
f"[INIT] Initializing HierarchicalSwarm: {self.name}"
835-
)
836831

837832
self.conversation = Conversation(time_enabled=False)
838833

@@ -854,11 +849,6 @@ def init_swarm(self):
854849
# Force refresh to ensure agents are displayed
855850
self.dashboard.force_refresh()
856851

857-
if self.verbose:
858-
logger.success(
859-
f"[SUCCESS] HierarchicalSwarm: {self.name} initialized successfully."
860-
)
861-
862852
if self.multi_agent_prompt_improvements:
863853
self.prepare_worker_agents()
864854

@@ -890,21 +880,13 @@ def add_context_to_director(self):
890880
Raises:
891881
Exception: If adding context fails due to agent configuration issues.
892882
"""
893-
try:
894-
if self.verbose:
895-
logger.info("[INFO] Adding agent context to director")
896-
897883
list_all_agents(
898884
agents=self.agents,
899885
conversation=self.conversation,
900886
add_to_conversation=True,
901887
add_collaboration_prompt=self.add_collaboration_prompt,
902888
)
903889

904-
if self.verbose:
905-
logger.success(
906-
"[SUCCESS] Agent context added to director successfully"
907-
)
908890

909891
except Exception as e:
910892
error_msg = (
@@ -928,14 +910,9 @@ def setup_director(self):
928910
Exception: If director setup fails due to configuration issues.
929911
"""
930912
try:
931-
if self.verbose:
932-
logger.info("[SETUP] Setting up director agent")
933913

934914
schema = BaseTool().base_model_to_dict(SwarmSpec)
935915

936-
if self.verbose:
937-
logger.debug(f"[SCHEMA] Director schema: {schema}")
938-
939916
return Agent(
940917
agent_name=self.director_name,
941918
agent_description="A director agent that can create a plan and distribute orders to agents",
@@ -964,10 +941,6 @@ def reliability_checks(self):
964941
ValueError: If the swarm configuration is invalid.
965942
"""
966943
try:
967-
if self.verbose:
968-
logger.info(
969-
f"Hiearchical Swarm: {self.name} Reliability checks in progress..."
970-
)
971944

972945
if not self.agents or len(self.agents) == 0:
973946
raise ValueError(
@@ -982,11 +955,6 @@ def reliability_checks(self):
982955
if self.director is None:
983956
self.director = self.setup_director()
984957

985-
if self.verbose:
986-
logger.success(
987-
f"Hiearchical Swarm: {self.name} Reliability checks passed..."
988-
)
989-
990958
except Exception as e:
991959
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"
992960
logger.error(error_msg)
@@ -1019,10 +987,6 @@ def run_director(
1019987
Exception: If director execution fails.
1020988
"""
1021989
try:
1022-
if self.verbose:
1023-
logger.info(
1024-
f"[RUN] Running director with task: {task}"
1025-
)
1026990

1027991
if self.planning_director_agent is not None:
1028992
plan = self.planning_director_agent.run(
@@ -1070,10 +1034,6 @@ def run_director(
10701034
role="Director", content=function_call
10711035
)
10721036

1073-
if self.verbose:
1074-
logger.success(
1075-
"[SUCCESS] Director execution completed"
1076-
)
10771037
logger.debug(
10781038
f"[OUTPUT] Director output type: {type(function_call)}"
10791039
)
@@ -1120,10 +1080,6 @@ def step(
11201080
Exception: If step execution fails.
11211081
"""
11221082
try:
1123-
if self.verbose:
1124-
logger.info(
1125-
f"[STEP] Executing single step for task: {task}"
1126-
)
11271083

11281084
# Update dashboard for director execution
11291085
if self.interactive and self.dashboard:
@@ -1134,10 +1090,6 @@ def step(
11341090
# Parse the orders
11351091
plan, orders = self.parse_orders(output)
11361092

1137-
if self.verbose:
1138-
logger.info(
1139-
f"[PARSE] Parsed plan and {len(orders)} orders"
1140-
)
11411093

11421094
# Update dashboard with plan and orders information
11431095
if self.interactive and self.dashboard:
@@ -1157,20 +1109,12 @@ def step(
11571109
outputs = self.execute_orders(
11581110
orders, streaming_callback=streaming_callback
11591111
)
1160-
1161-
if self.verbose:
1162-
logger.info(f"[EXEC] Executed {len(outputs)} orders")
1163-
1112+
11641113
if self.director_feedback_on is True:
11651114
feedback = self.feedback_director(outputs)
11661115
else:
11671116
feedback = outputs
11681117

1169-
if self.verbose:
1170-
logger.success(
1171-
"[SUCCESS] Step completed successfully"
1172-
)
1173-
11741118
return feedback
11751119

11761120
except Exception as e:
@@ -1227,19 +1171,8 @@ def run(
12271171
self.dashboard.start(self.max_loops)
12281172
self.dashboard.update_director_status("ACTIVE")
12291173

1230-
if self.verbose:
1231-
logger.info(
1232-
f"[START] Starting hierarchical swarm run: {self.name}"
1233-
)
1234-
logger.info(
1235-
f"[CONFIG] Configuration - Max loops: {self.max_loops}"
1236-
)
12371174

12381175
while current_loop < self.max_loops:
1239-
if self.verbose:
1240-
logger.info(
1241-
f"[LOOP] Loop {current_loop + 1}/{self.max_loops} - Processing task"
1242-
)
12431176

12441177
# Update dashboard loop counter
12451178
if self.interactive and self.dashboard:
@@ -1269,12 +1202,7 @@ def run(
12691202
*args,
12701203
**kwargs,
12711204
)
1272-
1273-
if self.verbose:
1274-
logger.success(
1275-
f"[SUCCESS] Loop {current_loop + 1} completed successfully"
1276-
)
1277-
1205+
12781206
except Exception as e:
12791207
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"
12801208
logger.error(error_msg)
@@ -1291,14 +1219,7 @@ def run(
12911219
if self.interactive and self.dashboard:
12921220
self.dashboard.update_director_status("COMPLETED")
12931221
self.dashboard.stop()
1294-
1295-
if self.verbose:
1296-
logger.success(
1297-
f"[COMPLETE] Hierarchical swarm run completed: {self.name}"
1298-
)
1299-
logger.info(
1300-
f"[STATS] Total loops executed: {current_loop}"
1301-
)
1222+
13021223

13031224
return history_output_formatter(
13041225
conversation=self.conversation, type=self.output_type
@@ -1350,8 +1271,6 @@ def feedback_director(self, outputs: list):
13501271
Exception: If feedback generation fails.
13511272
"""
13521273
try:
1353-
if self.verbose:
1354-
logger.info("[FEEDBACK] Generating director feedback")
13551274

13561275
task = f"History: {self.conversation.get_str()} \n\n"
13571276

@@ -1376,11 +1295,6 @@ def feedback_director(self, outputs: list):
13761295
role=self.director.agent_name, content=output
13771296
)
13781297

1379-
if self.verbose:
1380-
logger.success(
1381-
"[SUCCESS] Director feedback generated successfully"
1382-
)
1383-
13841298
return output
13851299

13861300
except Exception as e:
@@ -1421,9 +1335,6 @@ def call_single_agent(
14211335
Exception: If agent execution fails.
14221336
"""
14231337
try:
1424-
if self.verbose:
1425-
logger.info(f"[CALL] Calling agent: {agent_name}")
1426-
14271338
# Find agent by name
14281339
agent = None
14291340
for a in self.agents:
@@ -1488,12 +1399,6 @@ def agent_streaming_callback(chunk: str):
14881399
**kwargs,
14891400
)
14901401
self.conversation.add(role=agent_name, content=output)
1491-
1492-
if self.verbose:
1493-
logger.success(
1494-
f"[SUCCESS] Agent {agent_name} completed task successfully"
1495-
)
1496-
14971402
return output
14981403

14991404
except Exception as e:
@@ -1526,9 +1431,6 @@ def parse_orders(self, output):
15261431
Exception: If parsing fails due to other errors.
15271432
"""
15281433
try:
1529-
if self.verbose:
1530-
logger.info("[PARSE] Parsing director orders")
1531-
logger.debug(f"[TYPE] Output type: {type(output)}")
15321434

15331435
import json
15341436

@@ -1570,11 +1472,6 @@ def parse_orders(self, output):
15701472
]
15711473
]
15721474

1573-
if self.verbose:
1574-
logger.success(
1575-
f"[SUCCESS] Successfully parsed plan and {len(orders)} orders"
1576-
)
1577-
15781475
return plan, orders
15791476
except (
15801477
json.JSONDecodeError
@@ -1604,11 +1501,6 @@ def parse_orders(self, output):
16041501
]
16051502
]
16061503

1607-
if self.verbose:
1608-
logger.success(
1609-
f"[SUCCESS] Successfully parsed plan and {len(orders)} orders"
1610-
)
1611-
16121504
return plan, orders
16131505
except (
16141506
json.JSONDecodeError
@@ -1631,11 +1523,6 @@ def parse_orders(self, output):
16311523
for order in output["orders"]
16321524
]
16331525

1634-
if self.verbose:
1635-
logger.success(
1636-
f"[SUCCESS] Successfully parsed plan and {len(orders)} orders"
1637-
)
1638-
16391526
return plan, orders
16401527
else:
16411528
raise ValueError(
@@ -1678,9 +1565,6 @@ def execute_orders(
16781565
Exception: If order execution fails.
16791566
"""
16801567
try:
1681-
if self.verbose:
1682-
logger.info(f"[EXEC] Executing {len(orders)} orders")
1683-
16841568
outputs = []
16851569
for i, order in enumerate(orders):
16861570
if self.verbose:
@@ -1717,11 +1601,6 @@ def execute_orders(
17171601

17181602
outputs.append(output)
17191603

1720-
if self.verbose:
1721-
logger.success(
1722-
f"[SUCCESS] All {len(orders)} orders executed successfully"
1723-
)
1724-
17251604
return outputs
17261605

17271606
except Exception as e:
@@ -1761,14 +1640,6 @@ def batched_run(
17611640
Exception: If batched execution fails.
17621641
"""
17631642
try:
1764-
if self.verbose:
1765-
logger.info(
1766-
f"[START] Starting batched hierarchical swarm run: {self.name}"
1767-
)
1768-
logger.info(
1769-
f"[CONFIG] Configuration - Max loops: {self.max_loops}"
1770-
)
1771-
17721643
# Initialize a list to store the results
17731644
results = []
17741645

@@ -1783,20 +1654,7 @@ def batched_run(
17831654
)
17841655
results.append(result)
17851656

1786-
if self.verbose:
1787-
logger.success(
1788-
f"[COMPLETE] Batched hierarchical swarm run completed: {self.name}"
1789-
)
1790-
logger.info(
1791-
f"[STATS] Total tasks processed: {len(tasks)}"
1792-
)
1793-
17941657
return results
17951658

17961659
except Exception as e:
17971660
error_msg = f"[ERROR] Batched hierarchical swarm run failed: {str(e)}"
1798-
if self.verbose:
1799-
logger.error(error_msg)
1800-
logger.error(
1801-
f"[TRACE] Traceback: {traceback.format_exc()}"
1802-
)

0 commit comments

Comments
 (0)