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