Skip to content

Commit 1d2368b

Browse files
committed
Merge remote-tracking branch 'origin/master' into HEAD
# Conflicts: # swarms/structs/agent.py # swarms/utils/get_reasoning_efforts.py # tests/structs/test_agent.py
2 parents e89bd62 + 7243327 commit 1d2368b

27 files changed

Lines changed: 1009 additions & 4145 deletions

CLAUDE.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1086,8 +1086,6 @@ from swarms import Agent
10861086

10871087
**Don't instantiate heavyweight structures inside tight loops** — create agents and workflows once, reuse them across calls.
10881088

1089-
**Don't pass `tools=[]` (empty list)** — pass `tools=None` instead. An empty list can confuse schema generation.
1090-
10911089
**Don't use `streaming_on=True` and `streaming_callback` together on the same agent**`streaming_on` streams to stdout; `streaming_callback` streams to your function. Pick one.
10921090

10931091
**Don't set `context_compression=False` on very long autonomous sessions** — without compression the agent will eventually hit the context limit and raise an error.

examples/multi_agent/hierarchical_swarm/example_hierarchical.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
"""
2-
Hierarchical Multi-Agent Example
3-
4-
This example demonstrates hierarchical execution using HierarchicalSwarm,
5-
where a director agent coordinates worker agents: creates plans, assigns tasks,
6-
and iterates on results.
7-
8-
Use Case: Project execution where a director delegates to specialized teams.
9-
"""
10-
111
from swarms import Agent
122
from swarms.structs import HierarchicalSwarm
133

examples/multi_agent/hierarchical_swarm/hierarchical_swarm_autosave_example.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
#!/usr/bin/env python3
2-
"""
3-
HierarchicalSwarm Autosave Example
4-
5-
This example demonstrates how to use the autosave feature to automatically
6-
save conversation history after swarm execution.
7-
8-
Usage:
9-
python hierarchical_swarm_autosave_example.py
10-
"""
11-
121
from swarms import Agent, HierarchicalSwarm
132

143

examples/multi_agent/hierarchical_swarm/hierarchical_swarm_batch_demo.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,3 @@
1-
#!/usr/bin/env python3
2-
"""
3-
Hierarchical Swarm Batch Processing Demo
4-
5-
This demo shows how to use streaming callbacks with batch processing
6-
to handle multiple tasks sequentially with real-time feedback.
7-
"""
8-
91
import time
102
from typing import Callable
113
from swarms.structs.hiearchical_swarm import HierarchicalSwarm

pyproject.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
55

66
[tool.poetry]
77
name = "swarms"
8-
version = "14.0.0"
8+
version = "14.0.2"
99
description = "Swarms - TGSC"
1010
license = "Apache-2.0"
1111
authors = ["Kye Gomez <kye@swarms.world>"]
@@ -99,6 +99,9 @@ pytest = "*"
9999

100100
[tool.pytest.ini_options]
101101
testpaths = ["tests"]
102+
# Without this, pytest-asyncio's strict default silently skips every bare
103+
# `async def test_`, reporting it as a failure that never ran.
104+
asyncio_mode = "auto"
102105
markers = [
103106
"remote: tests that hit a real remote MCP server over the network",
104107
]

swarms/structs/agent.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ def __init__(
380380
reasoning_prompt_on: bool = True,
381381
dynamic_context_window: bool = True,
382382
show_tool_execution_output: bool = True,
383-
reasoning_effort: ReasoningEffort = "medium",
383+
reasoning_effort: Optional[ReasoningEffort] = None,
384384
thinking_tokens: int = 1024,
385385
think_tool: bool = False,
386386
dynamic_tools: bool = True,
@@ -411,7 +411,6 @@ def __init__(
411411
self.stopping_token = stopping_token
412412
self.interactive = interactive
413413
self.dashboard = dashboard
414-
self.saved_state_path = saved_state_path
415414
self.dynamic_temperature_enabled = dynamic_temperature_enabled
416415
self.dynamic_loops = dynamic_loops
417416
self.user_name = user_name
@@ -422,8 +421,8 @@ def __init__(
422421
self.system_prompt = system_prompt or ""
423422
self.agent_name = agent_name
424423
self.agent_description = agent_description
425-
# self.saved_state_path = f"{self.agent_name}_{generate_api_key(prefix='agent-')}_state.json"
426-
self.saved_state_path = (
424+
# Fallback: this once overwrote the caller's own path.
425+
self.saved_state_path = saved_state_path or (
427426
f"{generate_api_key(prefix='agent-')}_state.json"
428427
)
429428
self.autosave = autosave
@@ -664,9 +663,9 @@ def __init__(
664663
)
665664
self.system_prompt += "\n\n" + handoff_prompt
666665

667-
# One condition so the notice cannot diverge from the loader.
666+
# Not exists(): exists([]) is True, so tools=[] deferred.
668667
defers_tools = self.dynamic_tools and (
669-
exists(self.tools)
668+
bool(self.tools)
670669
or self.mcp_enabled
671670
or self.max_loops == "auto"
672671
)
@@ -675,7 +674,7 @@ def __init__(
675674
if defers_tools:
676675
self.system_prompt += DYNAMIC_TOOLS_NOTICE
677676
self.setup_dynamic_tools()
678-
elif exists(self.tools):
677+
elif self.tools:
679678
self.tool_handling()
680679

681680
if self.llm is None:

swarms/structs/auto_agent_builder.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
AUTO_AGENT_BUILDER_SYSTEM_PROMPT,
66
)
77
from swarms.structs.agent import Agent
8+
from swarms.structs.execution_utils import batched_run
89
from swarms.telemetry.otel import capture_init, trace_run
910
from swarms.utils.loguru_logger import initialize_logger
1011

@@ -430,3 +431,14 @@ def __call__(
430431
returns for this builder's ``return_dict`` setting.
431432
"""
432433
return self.run(task)
434+
435+
def batch_run(self, tasks: List[str]) -> Any:
436+
"""Generate the roster for each task in sequence.
437+
438+
Args:
439+
tasks (List[str]): The tasks the generated team should be able to handle.
440+
441+
Returns:
442+
List[Union[List[Agent], List[Dict[str, str]]]]: The rosters for each task.
443+
"""
444+
return batched_run(self.run, tasks)

swarms/structs/concat.py

Lines changed: 0 additions & 22 deletions
This file was deleted.

swarms/structs/mixture_of_agents.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ def __init__(
9494
max_loops: Stored configuration value for compatibility.
9595
output_type: Desired formatted output type.
9696
aggregator_model_name: Model used for the default aggregator.
97+
max_workers: Cap on concurrent worker agents per layer.
98+
aggegrator_args: Extra keyword arguments forwarded to the
99+
default aggregator agent. Ignored when ``aggregator_agent``
100+
is supplied.
97101
98102
Raises:
99103
ValueError: If no agents, aggregator system prompt, or layers
@@ -110,6 +114,7 @@ def __init__(
110114
self.output_type = output_type
111115
self.aggregator_model_name = aggregator_model_name
112116
self.max_workers = max_workers
117+
self.aggegrator_args = aggegrator_args or {}
113118

114119
self.reliability_check()
115120

swarms/telemetry/bootup.py

Lines changed: 47 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,55 @@
55
from loguru import logger
66

77

8+
def _prepare_workspace() -> None:
9+
"""
10+
Resolve ``WORKSPACE_DIR`` and make sure that directory exists.
11+
12+
Defers to :func:`ensure_workspace_env` rather than defaulting the variable
13+
here as well, so bootup and ``WorkspaceManager`` cannot drift apart — and
14+
so ``get_workspace_dir``'s ``lru_cache`` is invalidated when a default has
15+
to be invented.
16+
17+
A caller-supplied path that cannot be created falls back to the default
18+
instead of raising: an unusable workspace should not stop ``import
19+
swarms``, which is what an uncaught ``OSError`` here would do.
20+
"""
21+
# Imported here, not at module scope: swarms.utils.workspace_manager pulls
22+
# in swarms/utils/__init__, which calls initialize_logger at import. At
23+
# module scope that would run before WORKSPACE_DIR is settled, so the
24+
# logger would resolve its directory from the unprepared value.
25+
from swarms.utils.workspace_manager import ensure_workspace_env
26+
from swarms.utils.workspace_utils import get_workspace_dir
27+
28+
fallback = Path.cwd() / "agent_workspace"
29+
workspace = ensure_workspace_env() or str(fallback)
30+
31+
try:
32+
Path(workspace).mkdir(parents=True, exist_ok=True)
33+
return
34+
except OSError as e:
35+
# Covers unwritable paths and a WORKSPACE_DIR that already exists as a
36+
# file, which exist_ok does not suppress.
37+
logger.warning(
38+
f"WORKSPACE_DIR={workspace!r} could not be created ({e}); "
39+
f"falling back to {fallback}"
40+
)
41+
42+
os.environ["WORKSPACE_DIR"] = str(fallback)
43+
get_workspace_dir.cache_clear()
44+
try:
45+
fallback.mkdir(parents=True, exist_ok=True)
46+
except OSError as e:
47+
logger.warning(
48+
f"Default workspace {fallback} is unavailable too: {e}"
49+
)
50+
51+
852
def bootup():
953
"""Super-fast initialization of swarms environment"""
1054
try:
1155
# Cache env vars
1256
verbose = os.getenv("SWARMS_VERBOSE_GLOBAL", "False").lower()
13-
workspace_path = Path.cwd() / "agent_workspace"
1457

1558
# Configure logging early
1659
if verbose == "false":
@@ -21,10 +64,9 @@ def bootup():
2164
# Silence wandb
2265
os.environ["WANDB_SILENT"] = "true"
2366

24-
# Setup workspace dir only if needed
25-
if not workspace_path.exists():
26-
workspace_path.mkdir(parents=True, exist_ok=True)
27-
os.environ["WORKSPACE_DIR"] = str(workspace_path)
67+
# Only default it. Assigning unconditionally discarded whatever the
68+
# caller had exported, so WORKSPACE_DIR never survived `import swarms`.
69+
_prepare_workspace()
2870

2971
# Suppress deprecation warnings
3072
warnings.filterwarnings("ignore", category=DeprecationWarning)

0 commit comments

Comments
 (0)