Skip to content

Commit 50e9d0e

Browse files
authored
Merge pull request #1336 from hughiwnl/autosavedocs
Updated docs for autosave feature
2 parents e4324fa + d88178c commit 50e9d0e

File tree

3 files changed

+76
-5
lines changed

3 files changed

+76
-5
lines changed

docs/swarms/examples/concurrent_workflow.md

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,16 +175,28 @@ workflow = ConcurrentWorkflow(
175175
)
176176
```
177177

178-
#### Conversation History Management
178+
## Autosave Feature
179179

180-
Automatic conversation tracking and persistence:
180+
Autosave is enabled by default (`autosave=True`). Conversation history is automatically saved to `{workspace_dir}/swarms/ConcurrentWorkflow/{workflow-name}-{timestamp}/conversation_history.json`.
181+
182+
To set a custom workspace directory name, use the `WORKSPACE_DIR` environment variable:
181183

182184
```python
185+
import os
186+
from swarms import Agent, ConcurrentWorkflow
187+
188+
# Set custom workspace directory where conversation history will be saved
189+
# If not set, defaults to 'agent_workspace' in the current directory
190+
os.environ["WORKSPACE_DIR"] = "my_project"
191+
192+
# Create workflow (autosave enabled by default)
183193
workflow = ConcurrentWorkflow(
184-
agents=agents,
185-
auto_save=True, # Auto-save conversation history
186-
metadata_output_path="results.json" # Custom output file path
194+
name="analysis-workflow",
195+
agents=[analyst1, analyst2, analyst3],
187196
)
197+
198+
# Run workflow - conversation automatically saved
199+
result = workflow.run("Analyze market trends")
188200
```
189201

190202
#### Multimodal Support

docs/swarms/structs/hierarchical_swarm.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ Initializes a new HierarchicalSwarm instance.
6666
| `multi_agent_prompt_improvements` | `bool` | `False` | No | Enable enhanced multi-agent collaboration prompts |
6767
| `interactive` | `bool` | `False` | No | Enable interactive mode with Hierarchical Swarms dashboard visualization |
6868
| `planning_enabled` | `bool` | `True` | No | Enable planning phase before task distribution |
69+
| `autosave` | `bool` | `True` | No | Whether to enable autosaving of conversation history |
70+
| `verbose` | `bool` | `False` | No | Whether to enable verbose logging |
6971

7072
#### Returns
7173

@@ -481,6 +483,31 @@ The dashboard automatically:
481483
| **Detailed View** | Full output history for each agent in each loop |
482484
| **Real-time Updates** | Dashboard refreshes automatically as operations progress |
483485

486+
## Autosave Feature
487+
488+
Autosave is enabled by default (`autosave=True`). Conversation history is automatically saved to `{workspace_dir}/swarms/HierarchicalSwarm/{swarm-name}-{timestamp}/conversation_history.json` after all loops complete.
489+
490+
To set a custom workspace directory name, use the `WORKSPACE_DIR` environment variable:
491+
492+
```python
493+
import os
494+
from swarms import Agent, HierarchicalSwarm
495+
496+
# Set custom workspace directory where conversation history will be saved
497+
# If not set, defaults to 'agent_workspace' in the current directory
498+
os.environ["WORKSPACE_DIR"] = "my_project"
499+
500+
# Create swarm (autosave enabled by default)
501+
swarm = HierarchicalSwarm(
502+
name="analysis-swarm",
503+
agents=[research_agent, financial_agent],
504+
max_loops=2,
505+
)
506+
507+
# Run swarm - conversation automatically saved after all loops
508+
result = swarm.run("Analyze Tesla (TSLA) stock")
509+
```
510+
484511
## Planning Feature
485512

486513
The `planning_enabled` parameter controls whether the director performs an initial planning phase before creating task orders. When enabled, the director:
@@ -596,6 +623,7 @@ def live_paragraph_callback(agent_name: str, chunk: str, is_final: bool):
596623
| **Planning Strategy** | Enable `planning_enabled` for complex tasks, disable for simple or performance-critical tasks |
597624
| **Interactive Dashboard** | Use `interactive=True` during development for real-time monitoring and debugging |
598625
| **Context Preservation** | Leverage the built-in conversation history for continuity |
626+
| **Autosave Configuration** | Keep `autosave=True` (default) to preserve conversation history for debugging and analysis |
599627
| **Error Handling** | Implement proper error handling for production use |
600628
| **Streaming Callbacks** | Use streaming callbacks for real-time monitoring and user feedback |
601629
| **Callback Performance** | Keep streaming callbacks lightweight to avoid blocking the main execution thread |

docs/swarms/structs/sequential_workflow.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,11 @@ graph TD
3434
| `shared_memory_system` | `callable` | Optional callable for managing shared memory between agents. |
3535
| `multi_agent_collab_prompt` | `bool` | If True, appends a collaborative prompt to each agent's system prompt. |
3636
| `team_awareness` | `bool` | Enables sequential awareness features (passed to internal `AgentRearrange`). Defaults to `False`. |
37+
| `autosave` | `bool` | Whether to enable autosaving of conversation history. Defaults to `True`. |
38+
| `verbose` | `bool` | Whether to enable verbose logging. Defaults to `False`. |
3739
| `flow` | `str` | A string representing the order of agents (e.g., "Agent1 -> Agent2 -> Agent3"). |
3840
| `agent_rearrange`| `AgentRearrange` | Internal helper for managing agent execution. |
41+
| `swarm_workspace_dir` | `str` | The workspace directory where conversation history is saved (set automatically when autosave is enabled). |
3942

4043
## Methods
4144

@@ -53,6 +56,8 @@ The constructor initializes the `SequentialWorkflow` object.
5356
- `shared_memory_system` (`callable`, optional): Callable for shared memory management. Defaults to `None`.
5457
- `multi_agent_collab_prompt` (`bool`, optional): If True, appends a collaborative prompt to each agent's system prompt. Defaults to `False`.
5558
- `team_awareness` (`bool`, optional): Enables sequential awareness features in the underlying `AgentRearrange`. Defaults to `False`.
59+
- `autosave` (`bool`, optional): Whether to enable autosaving of conversation history. Defaults to `True`.
60+
- `verbose` (`bool`, optional): Whether to enable verbose logging. Defaults to `False`.
5661
- `*args`: Variable length argument list.
5762
- `**kwargs`: Arbitrary keyword arguments.
5863

@@ -308,6 +313,32 @@ print(result)
308313
| `description` | Description of workflow purpose | Standard description |
309314
| `max_loops` | Number of times to execute workflow | 1 |
310315
| `team_awareness` | Enable sequential awareness features | False |
316+
| `autosave` | Enable automatic saving of conversation history | True |
317+
| `verbose` | Enable verbose logging | False |
318+
319+
## Autosave Feature
320+
321+
Autosave is enabled by default (`autosave=True`). Conversation history is automatically saved to `{workspace_dir}/swarms/SequentialWorkflow/{workflow-name}-{timestamp}/conversation_history.json`.
322+
323+
To set a custom workspace directory name, use the `WORKSPACE_DIR` environment variable:
324+
325+
```python
326+
import os
327+
from swarms import Agent, SequentialWorkflow
328+
329+
# Set custom workspace directory where conversation history will be saved
330+
# If not set, defaults to 'agent_workspace' in the current directory
331+
os.environ["WORKSPACE_DIR"] = "my_project"
332+
333+
# Create workflow (autosave enabled by default)
334+
workflow = SequentialWorkflow(
335+
name="content-workflow",
336+
agents=[writer, editor],
337+
)
338+
339+
# Run workflow - conversation automatically saved
340+
result = workflow.run("Write a blog post about AI")
341+
```
311342

312343
## Best Practices
313344

0 commit comments

Comments
 (0)