Skip to content

Commit 78632c7

Browse files
committed
[bugf][swarm-router][drop "auto" from SwarmType, which had no factory entry (kyegomez#2057)]
"auto" was a member of the SwarmType Literal but absent from _initialize_swarm_factory, so reliability_check accepted it at construction and the first run() raised. A caller reading the type hint, or an IDE completing it, saw a legitimate option that always failed later. Removed rather than implemented: the class docstring's supported list and its factory-backed list both already exclude it, and there is no auto-selection anywhere in the file. Construction now rejects it with the same message that lists the valid types, which is what "AutoSwarmBuilder" already does. CLAUDE.md advertised it in the swarm_type table and the choosing-a-structure table; both now point at AutoSwarmBuilder. test_run_with_auto asserted the old behaviour and failed on master. It now pins that the value is absent from the Literal and rejected at construction.
1 parent 7243327 commit 78632c7

3 files changed

Lines changed: 16 additions & 15 deletions

File tree

CLAUDE.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ result = router.run("Write a blog post about transformer architectures.")
510510
| `"BatchedGridWorkflow"` | Grid-based batch execution |
511511
| `"LLMCouncil"` | LLM-based council decisions |
512512
| `"AutoSwarmBuilder"` | Auto-configures everything |
513-
| `"auto"` | Router selects swarm_type automatically |
514513

515514
---
516515

@@ -938,7 +937,7 @@ agent = Agent(
938937
| High-stakes ruling with deliberation | `CouncilAsAJudge` |
939938
| Structured adversarial debate | `DebateWithJudge` |
940939
| Deep research, many loops | `HeavySwarm` |
941-
| Don't know yet / rapid prototyping | `AutoSwarmBuilder` or `SwarmRouter(swarm_type="auto")` |
940+
| Don't know yet / rapid prototyping | `AutoSwarmBuilder` |
942941
| Need to switch architectures easily | `SwarmRouter` |
943942

944943
---

swarms/structs/swarm_router.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ def _msg_batch_run_error(err: Exception, tb: str) -> str:
137137
"GroupChat",
138138
"MultiAgentRouter",
139139
"HierarchicalSwarm",
140-
"auto",
141140
"MajorityVoting",
142141
"CouncilAsAJudge",
143142
"HeavySwarm",
@@ -303,7 +302,7 @@ def __init__(
303302
description: str = "Routes your task to the desired swarm",
304303
max_loops: int = 1,
305304
agents: List[Union[Agent, Callable]] = [],
306-
swarm_type: SwarmType = "SequentialWorkflow", # "ConcurrentWorkflow" # "auto"
305+
swarm_type: SwarmType = "SequentialWorkflow",
307306
autosave: bool = False,
308307
rearrange_flow: str = None,
309308
output_type: OutputType = "dict",

tests/structs/test_swarm_router.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
from typing import get_args
23

34
from swarms.structs.swarm_router import (
45
SwarmRouter,
@@ -473,19 +474,21 @@ def test_run_with_hierarchical_swarm():
473474
assert result is not None
474475

475476

476-
def test_run_with_auto():
477-
"""SwarmRouter dispatches to 'auto' (embedding-based selection)."""
478-
sample_agents = create_sample_agents()
479-
480-
router = SwarmRouter(
481-
agents=sample_agents,
482-
swarm_type="auto",
483-
max_loops=1,
484-
verbose=False,
477+
def test_auto_is_rejected_at_construction():
478+
from swarms.structs.swarm_router import (
479+
SwarmRouterConfigError,
480+
SwarmType,
485481
)
486482

487-
result = router.run("What is 1+1?")
488-
assert result is not None
483+
assert "auto" not in get_args(SwarmType)
484+
485+
with pytest.raises(SwarmRouterConfigError):
486+
SwarmRouter(
487+
agents=create_sample_agents(),
488+
swarm_type="auto",
489+
max_loops=1,
490+
verbose=False,
491+
)
489492

490493

491494
def test_run_with_majority_voting():

0 commit comments

Comments
 (0)