strands-swarms 0.1.1__py3-none-any.whl → 0.1.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,391 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: strands-swarms
3
- Version: 0.1.1
4
- Summary: Task-based workflow orchestration for Strands Agents
5
- Project-URL: Homepage, https://github.com/JackXu0/strands-swarms
6
- Project-URL: Issues, https://github.com/JackXu0/strands-swarms/issues
7
- Author-email: Zhuocheng Xu <zhuocheng.xu@icloud.com>
8
- License: Apache-2.0
9
- License-File: LICENSE
10
- Classifier: Development Status :: 3 - Alpha
11
- Classifier: Intended Audience :: Developers
12
- Classifier: License :: OSI Approved :: Apache Software License
13
- Classifier: Operating System :: OS Independent
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.10
16
- Classifier: Programming Language :: Python :: 3.11
17
- Classifier: Programming Language :: Python :: 3.12
18
- Classifier: Programming Language :: Python :: 3.13
19
- Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
- Requires-Python: >=3.10
21
- Requires-Dist: strands-agents>=0.1.0
22
- Provides-Extra: dev
23
- Requires-Dist: mypy>=1.15.0; extra == 'dev'
24
- Requires-Dist: pytest-asyncio>=1.0.0; extra == 'dev'
25
- Requires-Dist: pytest>=8.0.0; extra == 'dev'
26
- Requires-Dist: ruff>=0.13.0; extra == 'dev'
27
- Description-Content-Type: text/markdown
28
-
29
- # strands-swarms
30
-
31
- [![CI](https://github.com/JackXu0/strands-swarms/actions/workflows/ci.yml/badge.svg)](https://github.com/JackXu0/strands-swarms/actions/workflows/ci.yml)
32
- [![PyPI](https://img.shields.io/pypi/v/strands-swarms)](https://pypi.org/project/strands-swarms/)
33
- [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
34
-
35
- **Turn natural language into multi-agent workflows — automatically.**
36
-
37
- Give `DynamicSwarm` a query, and it automatically plans the workflow, spawns specialized agents, and executes tasks with dependencies. No manual graph configuration or agent wiring required.
38
-
39
- ```python
40
- swarm = DynamicSwarm(available_tools={...}, available_models={...})
41
- result = swarm.execute("Research AI trends and write a summary report")
42
- # → Spawns researcher + writer agents, handles dependencies, returns final report
43
- ```
44
-
45
- ## Why DynamicSwarm?
46
-
47
- | Traditional Multi-Agent | DynamicSwarm |
48
- |------------------------|--------------|
49
- | Manually define agents and roles | Agents spawned based on task needs |
50
- | Explicitly wire dependencies | Dependencies inferred from query |
51
- | Configure graph/swarm structure | Structure generated automatically |
52
- | Update code when workflow changes | Same code, different queries |
53
-
54
- **Key capabilities:**
55
- - **Automatic workflow planning** — LLM analyzes your query and designs the execution plan
56
- - **Dynamic agent spawning** — Creates only the agents needed, with appropriate tools
57
- - **Dependency-aware execution** — Tasks run in parallel when possible, sequential when required
58
- - **Zero configuration** — No graphs to define, no handoffs to code
59
-
60
- ## How It Works
61
-
62
- ![Architecture](assets/architecture.png)
63
-
64
- ```
65
- Query: "Research AI trends and write a summary report"
66
-
67
-
68
- ┌───────────────────────────────┐
69
- │ PHASE 1: PLANNING │
70
- │ Orchestrator analyzes │
71
- │ query and designs workflow │
72
- └───────────────────────────────┘
73
-
74
- ┌──────────────┴──────────────┐
75
- ▼ ▼
76
- spawn_agent spawn_agent
77
- "researcher" "report_writer"
78
- tools: [search_web] tools: [write_file]
79
- │ │
80
- ▼ ▼
81
- create_task create_task
82
- "research_ai_trends" "write_summary_report"
83
- depends_on: [] depends_on: [research_ai_trends]
84
-
85
-
86
- ┌───────────────────────────────┐
87
- │ PHASE 2: EXECUTION │
88
- │ Tasks run based on their │
89
- │ dependencies (parallel │
90
- │ when possible) │
91
- └───────────────────────────────┘
92
-
93
-
94
- ┌───────────────────────────────┐
95
- │ PHASE 3: FINAL RESPONSE │
96
- │ Orchestrator synthesizes │
97
- │ all task outputs │
98
- └───────────────────────────────┘
99
-
100
-
101
- Final Result
102
- ```
103
-
104
- ## Installation
105
-
106
- ```bash
107
- pip install strands-swarms
108
- ```
109
-
110
- ## Quick Start
111
-
112
- ```python
113
- from strands import tool
114
- from strands.models import BedrockModel
115
- from strands_swarms import DynamicSwarm
116
-
117
- # Define your tools
118
- @tool
119
- def search_web(query: str) -> str:
120
- """Search the web for information."""
121
- return f"[Search Results for '{query}']\n- Result 1: Latest developments..."
122
-
123
- @tool
124
- def analyze_data(data: str) -> str:
125
- """Analyze data and extract insights."""
126
- return f"[Analysis]\nKey insights: ..."
127
-
128
- @tool
129
- def write_file(path: str, content: str) -> str:
130
- """Write content to a file."""
131
- return f"Successfully wrote {len(content)} characters to {path}"
132
-
133
- # Configure models
134
- powerful_model = BedrockModel(model_id="us.anthropic.claude-3-opus-20240229-v1:0")
135
- fast_model = BedrockModel(model_id="us.anthropic.claude-3-5-haiku-20241022-v1:0")
136
-
137
- # Create the swarm
138
- swarm = DynamicSwarm(
139
- available_tools={
140
- "search_web": search_web,
141
- "analyze_data": analyze_data,
142
- "write_file": write_file,
143
- },
144
- available_models={
145
- "powerful": powerful_model,
146
- "fast": fast_model,
147
- },
148
- orchestrator_model=powerful_model,
149
- default_agent_model="fast",
150
- )
151
-
152
- # Execute with natural language
153
- result = swarm.execute("Research the latest AI trends and write a summary report")
154
-
155
- print(f"Status: {result.status}")
156
- print(f"Agents spawned: {result.agents_spawned}")
157
- print(f"Tasks completed: {result.tasks_created}")
158
- print(f"Final response: {result.final_response}")
159
- ```
160
-
161
- ## Verbose Output
162
-
163
- Enable `verbose=True` to see real-time execution with color-coded agents:
164
-
165
- ```python
166
- swarm = DynamicSwarm(..., verbose=True)
167
- ```
168
-
169
- <details>
170
- <summary>Example output (colors: 🔵 researcher, 🟢 report_writer)</summary>
171
-
172
- ```
173
- ============================================================
174
- 🚀 DYNAMIC SWARM STARTING
175
- ============================================================
176
-
177
- 📝 Query: Research the latest AI trends and write a summary report
178
- 📦 Available tools: ['search_web', 'analyze_data', 'write_file', 'execute_code']
179
- 🧠 Available models: ['powerful', 'fast']
180
-
181
- ----------------------------------------
182
- 📐 PHASE 1: PLANNING
183
- ----------------------------------------
184
- <thinking>
185
- To analyze this request and design a workflow, we need:
186
-
187
- 1. A researcher agent to gather information on the latest AI trends using the search_web tool
188
- 2. A writer agent to create the summary report using the write_file tool
189
-
190
- The research should be completed before the writing can begin, so there is a dependency between the tasks.
191
-
192
- The search_web and write_file tools provide the key capabilities needed. The analyze_data and execute_code tools are not directly relevant for this request.
193
-
194
- The "powerful" model should be used for the agents to ensure high-quality research and writing. The "fast" model is less critical for this offline task.
195
-
196
- All the necessary tools and information are available to proceed with creating the agents and tasks to fulfill this request.
197
- </thinking>
198
- Tool #1: spawn_agent
199
- Tool #2: spawn_agent
200
- Tool #3: create_task
201
- Tool #4: create_task
202
- Tool #5: finalize_plan
203
-
204
- ········································
205
- 🤖 AGENTS
206
- ········································
207
-
208
- 🔵 [researcher]
209
- Role: Researches the latest AI trends
210
- Tools: ['search_web']
211
- Model: powerful
212
-
213
- 🟢 [report_writer]
214
- Role: Writes a summary report on the research findings
215
- Tools: ['write_file']
216
- Model: powerful
217
-
218
- ········································
219
- 📋 TASKS & DEPENDENCIES
220
- ········································
221
-
222
- 🔵 [research_ai_trends] → researcher
223
- Research the latest trends and advancements in artificial intelligence
224
- ⚡ Can start immediately
225
-
226
- 🟢 [write_summary_report] → report_writer
227
- Write a summary report on the AI trends research findings
228
- ⏳ Waits for: 🔵 research_ai_trends
229
-
230
- ········································
231
- ✅ PLAN READY — 2 agents, 2 tasks
232
- ········································
233
-
234
- ----------------------------------------
235
- ⚡ PHASE 2: EXECUTION
236
- ----------------------------------------
237
-
238
- 🔵 ▶️ research_ai_trends
239
- <thinking>
240
- To research the latest AI trends, the most relevant tool is search_web.
241
- This will allow me to find up-to-date information on AI trends.
242
- </thinking>
243
-
244
- Tool: search_web
245
- query: "latest AI trends"
246
-
247
- <result>
248
- Summary Report: Latest AI Trends
249
-
250
- Trend 1: Large Language Models — Models like GPT-3, PaLM, and Chinchilla
251
- have demonstrated remarkable language understanding and generation...
252
-
253
- Trend 2: Multimodal AI — DALL-E, Imagen, Stable Diffusion can generate
254
- highly realistic images from text descriptions...
255
-
256
- Trend 3: Robotics and Embodied AI — Advances in robotic perception,
257
- motor control, and task learning for real-world environments...
258
- </result>
259
- ✓ Completed
260
-
261
- 🟢 ▶️ write_summary_report
262
- <thinking>
263
- The research findings are ready. I'll structure the key trends into a
264
- clear summary report covering LLMs, multimodal AI, and robotics.
265
- </thinking>
266
-
267
- <result>
268
- Summary Report: Latest AI Trends
269
- [Full report content...]
270
- </result>
271
- ✓ Completed
272
-
273
- ----------------------------------------
274
- 🏁 EXECUTION COMPLETE
275
- ----------------------------------------
276
- Status: COMPLETED
277
- Agents: 2 | Tasks: 2
278
-
279
- <thinking>
280
- The agents have completed their tasks. The report covers:
281
- 1. Large language models becoming increasingly powerful
282
- 2. Multimodal AI advancing rapidly
283
- 3. Progress in robotics and embodied AI
284
- </thinking>
285
-
286
- <result>
287
- Here is a summary report on the latest trends in artificial intelligence:
288
-
289
- AI continues to advance rapidly across several key fronts. Large language models
290
- like GPT-3 and PaLM exhibit increasingly powerful natural language abilities.
291
- Multimodal AI can now generate realistic images from text descriptions. Robots
292
- are becoming more autonomous with advances in perception and motor control.
293
-
294
- The rapid pace of progress looks set to continue and accelerate in coming years.
295
- </result>
296
-
297
- ============================================================
298
- ✅ SWARM COMPLETED SUCCESSFULLY
299
- ============================================================
300
- ```
301
-
302
- </details>
303
-
304
- ## Custom Event Handling
305
-
306
- Use strands-compatible hooks for programmatic event handling:
307
-
308
- ```python
309
- from strands_swarms import (
310
- DynamicSwarm,
311
- HookProvider,
312
- HookRegistry,
313
- AgentSpawnedEvent,
314
- TaskCompletedEvent,
315
- SwarmCompletedEvent,
316
- )
317
-
318
- class MyHookProvider(HookProvider):
319
- def register_hooks(self, registry: HookRegistry, **kwargs) -> None:
320
- registry.add_callback(AgentSpawnedEvent, self._on_agent)
321
- registry.add_callback(TaskCompletedEvent, self._on_task)
322
- registry.add_callback(SwarmCompletedEvent, self._on_complete)
323
-
324
- def _on_agent(self, event: AgentSpawnedEvent) -> None:
325
- print(f"🤖 Agent '{event.name}' spawned")
326
-
327
- def _on_task(self, event: TaskCompletedEvent) -> None:
328
- print(f"✓ Task '{event.name}' completed")
329
-
330
- def _on_complete(self, event: SwarmCompletedEvent) -> None:
331
- print(f"🏁 Done! {event.agents_spawned} agents, {event.tasks_completed} tasks")
332
-
333
- swarm = DynamicSwarm(..., hooks=[MyHookProvider()])
334
- ```
335
-
336
- Available events: `AgentSpawnedEvent`, `TaskCreatedEvent`, `TaskStartedEvent`, `TaskCompletedEvent`, `SwarmCompletedEvent`, `SwarmFailedEvent`
337
-
338
- ## When to Use the SDK Directly
339
-
340
- `DynamicSwarm` is for **dynamic workflows** where the structure is determined at runtime from natural language.
341
-
342
- For **static workflows** where you know the agents and structure upfront, use the official Strands SDK directly:
343
-
344
- ```python
345
- from strands import Agent
346
- from strands.multiagent.swarm import Swarm
347
- from strands.multiagent.graph import GraphBuilder
348
-
349
- # Swarm - dynamic handoffs with shared context
350
- researcher = Agent(name="researcher", system_prompt="You research topics.")
351
- analyzer = Agent(name="analyzer", system_prompt="You analyze data.")
352
- swarm = Swarm([researcher, analyzer])
353
- result = swarm("Research and analyze AI trends")
354
-
355
- # Graph - explicit dependency-based execution
356
- builder = GraphBuilder()
357
- builder.add_node(researcher, "research")
358
- builder.add_node(analyzer, "analyze")
359
- builder.add_edge("research", "analyze")
360
- graph = builder.build()
361
- result = graph("Research AI trends")
362
- ```
363
-
364
- See the SDK docs:
365
- - [`strands.multiagent.swarm.Swarm`](https://github.com/strands-agents/sdk-python/blob/main/src/strands/multiagent/swarm.py)
366
- - [`strands.multiagent.graph.Graph`](https://github.com/strands-agents/sdk-python/blob/main/src/strands/multiagent/graph.py)
367
-
368
- ## Inspiration
369
-
370
- This project is inspired by [Kimi K2.5's Agent Swarm](https://www.kimi.com/blog/kimi-k2-5.html) — where a trainable orchestrator dynamically creates and coordinates sub-agents without predefined roles or workflows. The goal is to build an open-source foundation for training orchestrators that can spin up agent swarms on the fly.
371
-
372
- ## Status & Roadmap
373
-
374
- > **Current version: Rollout-only**
375
- >
376
- > This release supports **rollout execution** (string-in, string-out) — ideal for inference and deployment.
377
- >
378
- > **Coming soon:** RL support via [strands-sglang](https://github.com/strands-agents/strands-sglang) integration.
379
-
380
- - [x] Rollout execution — string-in, string-out multi-agent workflows
381
- - [x] Dynamic orchestration — automatic agent creation and task assignment
382
- - [x] Event-driven monitoring — real-time status with hooks
383
- - [ ] RL support — training and fine-tuning via strands-sglang
384
-
385
- ## Contributing
386
-
387
- Contributions welcome! Please feel free to submit issues and pull requests.
388
-
389
- ## License
390
-
391
- Apache-2.0
@@ -1,9 +0,0 @@
1
- strands_swarms/__init__.py,sha256=eRu3XkDs5BqVR7QfOQ2mHQQwbzc1jTxVyBRLXdC3pEQ,2667
2
- strands_swarms/events.py,sha256=773eFDLXBPUwxXBmjh_pSJxBbALG5nzzVuiJtRPdTsI,19418
3
- strands_swarms/orchestrator.py,sha256=YAmGco0uFfZaTP9NFaSpZhyHkWh5fK72MmRaENvU12E,7448
4
- strands_swarms/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- strands_swarms/swarm.py,sha256=Cwj-zIgFnSbxXjeOrZo865UTV30fUhYk6xp9HSN__eE,27270
6
- strands_swarms-0.1.1.dist-info/METADATA,sha256=0svpMJzAAhhnVRKzuIkTZdS5cytKBFV36fSPNpThnQg,14769
7
- strands_swarms-0.1.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
8
- strands_swarms-0.1.1.dist-info/licenses/LICENSE,sha256=fw8CKBXZ_-V6K5pxfUmJP3e_7QUvFq8XncuZ27tvarg,10177
9
- strands_swarms-0.1.1.dist-info/RECORD,,