From 180674ca53800432e30527856f4ab82014455197 Mon Sep 17 00:00:00 2001 From: CI-DEV <154627941+IlumCI@users.noreply.github.com> Date: Tue, 25 Nov 2025 22:59:19 +0200 Subject: [PATCH] Clarify Rich tree visualization usage in print_swarm_structure Added a note about Rich tree visualization limitations for non-HierarchicalSwarm instances. --- swarms/utils/formatter.py | 9 +++++++++ 1 file changed, 9 insertions(+) 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}")