Skip to content

Commit e89bd62

Browse files
committed
Merge remote-tracking branch 'origin/master' into HEAD
# Conflicts: # swarms/structs/agent_loader.py # swarms/utils/get_reasoning_efforts.py
2 parents 40bc5f1 + f8e3fff commit e89bd62

26 files changed

Lines changed: 924 additions & 6266 deletions

examples/changelogs/v14-zena/08_computer_use_tools.py

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

examples/changelogs/v14-zena/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ A few examples reference other providers (`claude-sonnet-4-6` in the hierarchica
2424
| [05_auction_swarm.py](05_auction_swarm.py) | AuctionSwarm | Agents bidding on a task; default and custom scoring |
2525
| [06_groupchat_turn_based.py](06_groupchat_turn_based.py) | Turn-Based GroupChat | Single-speaker bidding with a recency penalty |
2626
| [07_hierarchical_swarm_recovery.py](07_hierarchical_swarm_recovery.py) | HierarchicalSwarm | Worker retry, task reassignment, planning, judge, director overrides |
27-
| [08_computer_use_tools.py](08_computer_use_tools.py) | Computer-Use Tools | Full toolset, and a read-only subset |
2827
| [09_class_to_pydantic.py](09_class_to_pydantic.py) | Pydantic Schemas | Schema from a constructor, and the round-trip back to an `Agent` |
2928
| [10_concurrent_workflow_on_error.py](10_concurrent_workflow_on_error.py) | ConcurrentWorkflow | `on_error` failure policy |
3029
| [11_graph_workflow.py](11_graph_workflow.py) | Performance | Fan-out/fan-in DAG on native rustworkx |

examples/tools/computer-use/computer-use-example.py

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

swarms/schemas/agent_errors.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
"""
2-
Exception hierarchy for :class:`swarms.structs.agent.Agent`.
3-
4-
These live here rather than in ``agent.py`` so that agent collaborators
5-
(``LLMManager``, ``SkillsManager``, ``MCPManager``, …) can raise and catch them
6-
without importing ``Agent`` itself, which would be circular. They remain
7-
importable from ``swarms.structs.agent`` for backwards compatibility.
8-
"""
9-
10-
111
class AgentError(Exception):
122
"""Base class for all agent-related exceptions."""
133

swarms/schemas/swarms_api_schemas.py

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

swarms/structs/agent_loader.py

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,16 @@
1010
Dict,
1111
List,
1212
TypedDict,
13-
TypeVar,
1413
Union,
1514
)
1615

1716
import yaml
17+
from pydantic import BaseModel
1818
from tqdm import tqdm
1919

2020
from swarms.agents.create_agents_from_yaml import (
2121
create_agents_from_yaml,
2222
)
23-
from swarms.schemas.swarms_api_schemas import AgentSpec
2423
from swarms.utils.types import ReturnTypes
2524
from swarms.structs.agent import Agent
2625
from swarms.utils.agent_loader_markdown import (
@@ -29,11 +28,6 @@
2928
MarkdownAgentLoader,
3029
)
3130

32-
# Type variable for agent configuration
33-
AgentConfigType = TypeVar(
34-
"AgentConfigType", bound=Union[AgentSpec, Dict[str, Any]]
35-
)
36-
3731

3832
class ModelName(str, Enum):
3933
"""Valid model names for swarms agents"""
@@ -101,12 +95,11 @@ class AgentValidator:
10195

10296
@staticmethod
10397
def validate_config(
104-
config: Union[AgentSpec, Dict[str, Any]],
98+
config: Union[BaseModel, Dict[str, Any]],
10599
) -> AgentConfigDict:
106-
"""Validate and convert agent configuration from either AgentSpec or Dict"""
100+
"""Validate a config supplied as a pydantic model or a plain dict."""
107101
try:
108-
# Convert AgentSpec to dict if needed
109-
if isinstance(config, AgentSpec):
102+
if isinstance(config, BaseModel):
110103
config = config.model_dump()
111104

112105
# Deferred: litellm must not load at `import swarms` time (#1754).
@@ -222,7 +215,7 @@ def file_type(self) -> FileType:
222215
raise ValueError(f"Unsupported file type: {ext}")
223216

224217
def create_agent_file(
225-
self, agents: List[Union[AgentSpec, Dict[str, Any]]]
218+
self, agents: List[Union[BaseModel, Dict[str, Any]]]
226219
) -> None:
227220
"""Create a file with validated agent configurations"""
228221
validated_agents = []
@@ -291,7 +284,7 @@ def load_agents(self) -> List[Agent]:
291284
return agents
292285

293286
def _process_agent(
294-
self, agent_data: Union[AgentSpec, Dict[str, Any]]
287+
self, agent_data: Union[BaseModel, Dict[str, Any]]
295288
) -> Union[Agent, None]:
296289
"""Process a single agent configuration"""
297290
try:

swarms/structs/hybrid_hiearchical_peer_swarm.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
)
1111
from typing import Union, Callable
1212
from swarms.utils.history_output_formatter import HistoryOutputType
13+
from swarms.utils.str_to_dict import str_to_dict
1314

1415
tools = [
1516
{
@@ -129,20 +130,6 @@ def __init__(
129130
output_type="final",
130131
)
131132

132-
def convert_str_to_dict(self, response: str):
133-
# Handle response whether it's a string or dictionary
134-
if isinstance(response, str):
135-
try:
136-
import json
137-
138-
response = json.loads(response)
139-
except json.JSONDecodeError:
140-
raise ValueError(
141-
"Invalid JSON response from router agent"
142-
)
143-
144-
return response
145-
146133
def run(self, task: str, *args, **kwargs):
147134
"""
148135
Runs the routing process for a given task.
@@ -164,9 +151,11 @@ def run(self, task: str, *args, **kwargs):
164151
response = self.router_agent.run(task=task)
165152

166153
if isinstance(response, str):
167-
response = self.convert_str_to_dict(response)
154+
response = str_to_dict(response)
168155
else:
169-
pass
156+
raise ValueError(
157+
f"Invalid response from router agent: response must be a string. Got {type(response)}."
158+
)
170159

171160
swarm_name = response.get("swarm_name")
172161
task_description = response.get("task_description")

swarms/tools/__init__.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,12 @@
1818
multi_base_model_to_openai_function,
1919
)
2020
from swarms.tools.tool_registry import ToolStorage, tool_registry
21-
from swarms.tools.computer_use import create_computer_use_tools
2221
from swarms.tools.tool_utils import (
2322
scrape_tool_func_docs,
2423
tool_find_by_name,
2524
)
2625

2726
__all__ = [
28-
"create_computer_use_tools",
2927
"scrape_tool_func_docs",
3028
"tool_find_by_name",
3129
"_remove_a_key",

0 commit comments

Comments
 (0)