Skip to content

Commit 216aabb

Browse files
committed
[V12 Examples]
1 parent 6a7ad5b commit 216aabb

12 files changed

Lines changed: 779 additions & 2 deletions
File renamed without changes.

examples/guides/v12_examples/02_context_compression.py renamed to examples/guides/v12_update/02_context_compression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"Summarise the history of artificial intelligence in 10 detailed paragraphs, "
1919
"then list the 20 most important researchers and their contributions."
2020
)
21-
print(result[:500], "...[truncated]")
21+
print(result)
2222

2323
# --- Agent with context compression disabled ---
2424
# Useful for short, predictable tasks where you want raw fidelity and

examples/guides/v12_examples/03_grep_tool_autonomous_loop.py renamed to examples/guides/v12_update/03_grep_tool_autonomous_loop.py

File renamed without changes.

examples/guides/v12_examples/04_conversation_memory_compact.py renamed to examples/guides/v12_update/04_conversation_memory_compact.py

File renamed without changes.

examples/guides/v12_examples/05_graph_workflow_callbacks.py renamed to examples/guides/v12_update/05_graph_workflow_callbacks.py

File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# swarms v12 — A Memory and Reliability Release
2+
3+
> Apache 2.0 · [github.com/kyegomez/swarms](https://github.com/kyegomez/swarms)
4+
>
5+
> **Contributors:** Kye Gomez · Steve-Dusty · adichaudhary · MycCellium420
6+
7+
---
8+
9+
## Introduction
10+
11+
Over a focused two-week sprint from April 18 to May 2, 2026, the swarms framework landed 35 commits from four contributors, broken down into 8 new features, 7 improvements, and 4 bug fixes, alongside 2 new test suites and 4 docs updates. Despite the volume of new functionality, the release is a net reduction of roughly 1 700 lines, as the senator-assembly module and the unused uvloop and winloop execution paths were retired in favour of a leaner core.
12+
13+
The headline additions all centre on agent memory and observability: persistent memory that survives process restarts by default, an automatic context compressor that summarises history once token usage crosses 90 %, a safe grep tool for the autonomous loop, and per-node completion plus token-streaming callbacks for GraphWorkflow. Conversation compaction now writes timestamped archive snapshots before rewriting active memory, and interactive mode picks up a Rich loading spinner and graceful keyboard-interrupt handling.
14+
15+
---
16+
17+
## Features
18+
19+
### Persistent Memory
20+
21+
Introducing persistent memory. Every agent now keeps its own long-term notebook on disk, so when you start it again tomorrow, next week, or after a crash, it remembers everything from before — there is nothing extra to set up, it just works the moment you create the agent. Persistent memory helps with long-running projects, ongoing conversations with a single agent, and any workflow where you do not want to re-explain context every time the process restarts. If you want a clean-slate agent for a one-off task, you can turn it off with a single switch.
22+
23+
### Grep Tool for the Autonomous Loop
24+
25+
Introducing the grep tool. When an autonomous agent needs to find something inside a codebase or a folder of text files, it can now search directly with a built-in tool instead of falling back to running shell commands. The grep tool helps with code exploration, finding TODOs, locating where a function is used, and any other "search the files for X" task — and because the search arguments are never fed into a shell, malicious input cannot turn into a command injection. The result is automatically capped in size so a huge match cannot flood the agent's working memory.
26+
27+
### Persistent Conversation Memory on Disk
28+
29+
Introducing on-disk conversation memory. The Conversation primitive — the part of the framework that holds an agent's chat history — now writes every message to a file as it happens and reloads that file the next time the same agent starts up. This helps with crash recovery, long-running tasks that span days, and any case where you want the agent's full message history to outlive a single Python process. The file is named after the agent rather than the run, so memory follows the agent identity instead of vanishing when the process exits.
30+
31+
### Context Compressor
32+
33+
Introducing the context compressor. Long-running agents used to eventually fill up their context window — the memory limit a model can hold in a single turn — and crash mid-task. The compressor helps with exactly this: it watches the conversation as it grows, and once it gets close to the limit it automatically summarises the older parts so the agent can keep going indefinitely without ever hitting the wall. You set a context length, and the framework keeps you safely under it.
34+
35+
### Conversation Compact with Archive Snapshots
36+
37+
Introducing compaction with archive snapshots. Whenever the framework summarises a long conversation to save space, it now first saves a complete copy of the original, untouched conversation with a timestamp on it. This helps with debugging, auditing, and post-mortems — even after the live memory has been condensed, you can always go back and see exactly what was said. Nothing is ever truly thrown away.
38+
39+
### Graceful Exit on Keyboard Interrupt
40+
41+
Introducing graceful exit. When you press Ctrl+C to stop an agent in interactive mode, it now shuts down cleanly and returns you to the prompt instead of crashing with a stack trace. This helps with everyday use, where you frequently want to interrupt a long generation or back out of a session without seeing an unhandled error each time. Small change, big quality-of-life win.
42+
43+
### Rich Loading Spinner in Interactive Mode
44+
45+
Introducing a loading spinner. While the agent is thinking and you are sitting in interactive mode waiting for a response, you now see an animated spinner instead of a frozen-looking screen. This helps with the constant "is this thing actually running?" feeling that came with longer tasks — you immediately know the agent is alive and working, even on requests that take a while.
46+
47+
### GraphWorkflow Callbacks
48+
49+
Introducing GraphWorkflow callbacks. When you run a graph of agents, you can now hook into two events: one that fires every time a single agent finishes its part, and one that streams the individual words of an agent's response as they are generated. These callbacks help with logging, progress bars, real-time UIs, and any case where you need to know what is happening inside a complex workflow without waiting for the whole thing to finish. You can watch the graph execute live instead of squinting at logs after the fact.
50+
51+
---
52+
53+
## Improvements
54+
55+
### Execution Prompt Written Once Per Subtask
56+
57+
The autonomous loop used to repeat the same instruction inside its own memory on every step, which made the model think it was being asked to redo work it had already finished. The instruction is now stored exactly once per subtask, so the agent moves forward instead of looping over the same ground.
58+
59+
### Skip the `think` Tool When Native Thinking Is Enabled
60+
61+
Some newer models have built-in thinking — they reason internally before answering. When that is turned on, the framework's own "think" helper tool was just adding extra back-and-forth for no benefit, so it is now hidden whenever the model already thinks for itself.
62+
63+
### Modernised `arun_stream` Async Behaviour
64+
65+
The async streaming function used to rely on a deprecated piece of Python's async machinery and quietly hide errors that happened in the background. It now uses the modern equivalent and surfaces any error to your code, so you can actually see and handle problems instead of having them swallowed silently.
66+
67+
### Faster `any_to_str` in AgentRearrange
68+
69+
Inside AgentRearrange there is a helper that turns arbitrary values into strings. The helper now first checks if the value is already a string and skips the conversion entirely if it is. On hot paths that touch this helper many times, that small check meaningfully reduces wasted work.
70+
71+
### Removed `uvloop` and `winloop` Dependencies
72+
73+
Two optional async libraries — uvloop and winloop — were listed as dependencies but never actually used in production code paths. They have been removed along with the dead functions that referenced them, shrinking the install footprint and removing a platform-specific package nobody needed.
74+
75+
### Timestamps in Conversation History
76+
77+
When you ask a Conversation for its history as a string, every message now carries an ISO timestamp showing exactly when it happened. That makes it dramatically easier to line conversations up against application logs or debug a sequence of events after the fact.
78+
79+
### Senator Assembly Module Removed
80+
81+
A deprecated simulation module called senator_assembly — more than 3 400 lines of code, plus its example file and the line that re-exported it — has been deleted. It is the single largest reason the release ends up shorter than it started.
82+
83+
---
84+
85+
## Bug Fixes
86+
87+
### Non-OpenAI Providers No Longer Return Empty Strings
88+
89+
A regression had been causing providers other than OpenAI — including Anthropic and Google — to return blank responses whenever the reasoning_effort setting was used. The fix restores normal output across every supported provider, so you no longer have to avoid the setting on non-OpenAI models.
90+
91+
### Streaming Thinking Panel No Longer Corrupts the Terminal
92+
93+
When the framework streamed an agent's "thinking" output into a Rich live display, it sometimes ended up scrambling the terminal — overlapping panels, cursors in the wrong place. The thinking output is now flushed and rendered before the live display starts, so the terminal stays clean throughout the run.
94+
95+
### `_generate_final_summary` Forwards `streaming_callback`
96+
97+
At the very end of an autonomous run there is a final-summary step. That step was forgetting to pass through your streaming callback, so the summary tokens were generated silently even when you had asked to receive them as they arrived. The callback now flows through correctly and you see the summary stream in real time.
98+
99+
### License Metadata Corrected to Apache 2.0
100+
101+
The project's package metadata was incorrectly marking it as MIT-licensed even though the actual LICENSE file is Apache 2.0. That mismatch is now fixed in both the package configuration and the standard licence classifier, so tools and registries see the correct, consistent licence.
102+
103+
---
104+
105+
## Tests
106+
107+
### MEMORY.md Persistence Coverage
108+
109+
A dedicated test suite now covers MEMORY.md round-trip persistence, compact-with-archive behaviour, and timestamp formatting in the history string. The new memory pipeline is exercised end-to-end rather than through mocks, so regressions in this critical area get caught immediately.
110+
111+
### Real-LLM Streaming and Autonomous-Loop Suite
112+
113+
A 71-test harness across 19 classes uses real Agent and LiteLLM instances to validate the streaming pipeline, async streaming behaviour, thinking-panel rendering, autonomous-loop fixes, and final-summary callback threading. Confidence in the streaming and loop paths is now backed by actual model calls, not stubs.
114+
115+
---
116+
117+
## Docs
118+
119+
### Agent Memory Guide
120+
121+
A new guide walks through the full memory flow — persistent memory, the context compressor, and compaction with archive snapshots. It is the canonical reference for everything memory-related introduced in v12.
122+
123+
### Persistent Memory and Context Compression Examples
124+
125+
The agent reference documentation gains a section dedicated to persistent_memory and context_compression with annotated example patterns. Readers can see the combined usage at a glance without piecing it together from the changelog.
126+
127+
### GraphWorkflow Streaming Callback Example
128+
129+
A complete runnable example demonstrates the new on_node_complete and streaming_callback hooks on GraphWorkflow. Anyone wiring up DAG observability has a copy-paste starting point.
130+
131+
### README Updates
132+
133+
Several README passes correct import paths so SwarmRouter, AutoSwarmBuilder, and AOP all resolve from the top-level swarms package, and refresh model-name references and integration examples to match current usage.
134+
135+
---
136+
137+
## Conclusion
138+
139+
v12 is fundamentally a memory and reliability release. The combination of persistent memory, the context compressor, conversation compaction with archive snapshots, and on-disk message history transforms the agent from a stateless request handler into a long-lived, restart-safe entity capable of running indefinitely without losing context, while the new grep tool meaningfully extends what the autonomous loop can do on real codebases.
140+
141+
The supporting work is just as important: 7 improvements tighten the autonomous loop and shed dead dependencies, 4 bug fixes resolve real production issues across non-OpenAI providers, streaming, and the final-summary phase, and 2 new test suites — including a 71-test real-LLM harness — back the new paths with end-to-end coverage rather than mocks. Across 35 commits and a net reduction of around 1 700 lines, the framework comes out of this sprint smaller, sharper, and more capable than it went in.

0 commit comments

Comments
 (0)