Skip to content

Commit 774fbce

Browse files
committed
trim comments to the load-bearing lines
1 parent 58c33b8 commit 774fbce

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

swarms/structs/hiearchical_swarm.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -730,24 +730,19 @@ def reliability_checks(self):
730730
elif not getattr(
731731
self.director, "tools_list_dictionary", None
732732
):
733-
# A caller-supplied director carries no SwarmSpec schema, so it
734-
# replies in prose and parse_orders can never read a plan out of
735-
# it. Attach the same schema setup_director() would have used.
733+
# Without the SwarmSpec schema a caller-supplied director
734+
# replies in prose and parse_orders never finds a plan.
736735
self.director.tools_list_dictionary = [
737736
BaseTool().base_model_to_dict(SwarmSpec)
738737
]
739-
# Agent bakes its tool schemas into the LiteLLM instance during
740-
# __init__, so the schema above only reaches the model once that
741-
# instance is rebuilt -- the same step Agent takes when it adds
742-
# planning tools after construction.
738+
# Agent bakes tool schemas into LiteLLM at __init__, so the
739+
# schema only reaches the model once that instance is rebuilt.
743740
if getattr(self.director, "llm", None) is not None:
744741
self.director.llm = self.director.llm_handling()
745742

746-
# The schema alone is not enough: without the director prompt the
747-
# model invents field names (e.g. "agent" for "agent_name") and
748-
# HierarchicalOrder rejects the order. Append to short_memory
749-
# rather than system_prompt, which Agent already copied into its
750-
# conversation during __init__.
743+
# Without the prompt the model invents field names ("agent"
744+
# for "agent_name"). short_memory, not system_prompt: Agent
745+
# already copied that into its conversation at __init__.
751746
memory = getattr(self.director, "short_memory", None)
752747
if memory is not None:
753748
memory.add(
@@ -1003,8 +998,8 @@ def run(
1003998
content=f"--- Loop {current_loop}/{self.max_loops} completed ---",
1004999
)
10051000

1006-
# Every loop failed, so the conversation holds no agent work. Returning
1007-
# it would look like a successful run that simply produced nothing.
1001+
# No agent work in the conversation; returning it would read as a
1002+
# successful run that produced nothing.
10081003
if failed_loops == self.max_loops:
10091004
raise RuntimeError(
10101005
f"Hierarchical swarm produced no output: all {self.max_loops} "

0 commit comments

Comments
 (0)