From f9a299831d7ce5943558435c4188c3b8b78f714d Mon Sep 17 00:00:00 2001 From: Hugh <155223694+hughiwnl@users.noreply.github.com> Date: Thu, 4 Dec 2025 03:43:22 -0800 Subject: [PATCH] added round robin to swarm router --- swarms/structs/swarm_router.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/swarms/structs/swarm_router.py b/swarms/structs/swarm_router.py index ed9659c0..27f70bd6 100644 --- a/swarms/structs/swarm_router.py +++ b/swarms/structs/swarm_router.py @@ -39,6 +39,7 @@ from swarms.utils.generate_keys import generate_api_key from swarms.utils.loguru_logger import initialize_logger from swarms.utils.output_types import OutputType from swarms.structs.llm_council import LLMCouncil +from swarms.structs.round_robin import RoundRobinSwarm logger = initialize_logger(log_folder="swarm_router") @@ -60,6 +61,7 @@ SwarmType = Literal[ "BatchedGridWorkflow", "LLMCouncil", "DebateWithJudge", + "RoundRobin", ] @@ -157,6 +159,7 @@ class SwarmRouter: - MixtureOfAgents: Combines multiple agent types for diverse tasks - SequentialWorkflow: Executes tasks sequentially - ConcurrentWorkflow: Executes tasks in parallel + - RoundRobin: Executes tasks in a round-robin fashion, cycling through agents - "auto": Automatically selects best swarm type via embedding search Methods: @@ -425,6 +428,7 @@ class SwarmRouter: "BatchedGridWorkflow": self._create_batched_grid_workflow, "LLMCouncil": self._create_llm_council, "DebateWithJudge": self._create_debate_with_judge, + "RoundRobin": self._create_round_robin_swarm, } def _create_heavy_swarm(self, *args, **kwargs): @@ -599,6 +603,19 @@ class SwarmRouter: **kwargs, ) + def _create_round_robin_swarm(self, *args, **kwargs): + """Factory function for RoundRobinSwarm.""" + return RoundRobinSwarm( + name=self.name, + description=self.description, + agents=self.agents, + max_loops=self.max_loops, + verbose=self.verbose, + return_json_on=self.return_json, + *args, + **kwargs, + ) + def _create_swarm(self, task: str = None, *args, **kwargs): """ Dynamically create and return the specified swarm type with O(1) lookup performance.