diff --git a/swarms/utils/formatter.py b/swarms/utils/formatter.py index 83f01d6f..d9d88bc8 100644 --- a/swarms/utils/formatter.py +++ b/swarms/utils/formatter.py @@ -934,6 +934,9 @@ class Formatter: def print_swarm_structure(self, swarm: Any, title: str = "Nested Structure:") -> None: """ Print a visual tree representation of a nested swarm structure using Rich Tree. + + Note: Rich tree visualization is only available for HierarchicalSwarm instances. + Other swarm types will not be visualized. Args: swarm (Any): The root swarm object to visualize. @@ -942,6 +945,12 @@ class Formatter: if not swarm: return + # Only use Rich tree for HierarchicalSwarm instances + swarm_type_name = type(swarm).__name__ + if swarm_type_name != "HierarchicalSwarm": + # For non-HierarchicalSwarm types, do nothing + return + # Always print title first using regular print to ensure visibility print(f"\n{title}")