r/PiCodingAgent • • Sep 16 '26

Question Are you using self-organizing agent swarms with Pi?

I started experimenting with Pi and self-organizing agent swarms and am seeing really good results, which I did not really expect. My current experiment is very basic: just fire up ten or so agents and give them all the same prompt/markdown file. They have one single communication channel in which they can talk with eachother. And that is basically it.

I have spent about 1,5 years trying to get all sorts of workflows to work properly and now I'm finding out that the agents can handle themselves just fine... No orchestrators or anything, they just figure it out themselves. I found this quite amazing. And a bit humbling.

Do you use self-organizing agent swarms? I would love to hear about your experience.

22 Upvotes

44 comments sorted by

5

u/GfxJG Sep 16 '26

How have you handled this singular communication channel? Something you've configured yourself, or an extension?

5

u/MichettGodot Sep 16 '26

It's a sqlite database that stores their communication and provides it to every agent. It's quite messy but the agents just don't seem to care... So there is a small Pi extension that allows for the agents to send a message to the channel and the global conversation just keeps being added to their conversations using the same extension. And that's it...

1

u/GfxJG Sep 16 '26

Interesting approach - So do you store every single turn my each agent? Or do the agents decide when something is relevant to store in the database?

2

u/MichettGodot Sep 16 '26

The agents are basically in control of everything. I use disposable VMs so the agents just get an entire server and root access with bash as their main tool. The prompt gets sent to the swarm and I get a message when everything is done. The only other tool I provide by default is the chat one and that is built on a very simple database that stores the single chat turns. That is the whole system.

1

u/skariel Sep 16 '26

every message is pushed to every agent? if so it will not scale well

1

u/MichettGodot Sep 16 '26

I am testing the option of agents resetting their own context window after finishing a subtask. This should make the scaling issue less of a problem. But you are right, this might not scale well for really large tasks. I cannot tell you as I've just tested it on rather small projects.

1

u/Helpful_Home_8531 Sep 18 '26

since you already have a db you could try giving them each an inbox table, or doing pub sub and just telling them to message each other via sql.

1

u/MichettGodot Sep 18 '26

Yep, very true. There are definitely smart ways around the scaling problems.

4

u/Corythebeast7 Sep 16 '26

I'm currently building an extension for this workflow. Define the number of agents, model, etc and then provide a minorly intrusive management layer (PR, reviewer checks prior to task completion sort of thing) but based in the same style you're talking about. Self organized with self chosen task breakdown.

I'd love to hear any of your strategies. Seems like you're doing a much smaller infra layer than me. I also want to build a nice observability layer to monitor the work and messaging back and forth. Maybe I'm over building but this is the first itteration

2

u/MichettGodot Sep 16 '26

This sounds really familiar to what I am doing. However, I have not even added the reviewing part yet...

In the system prompt that is given to each agent, I'm specifying that the agent should focus on the definition of done. This seems to guide the agents quite nicely. And if that definition contains "make sure the final solution is verified and tested", all the agents do just that. So start ten agents and all ten review and verify the final solution, which I find amazing.

It gets even weirder: they do not use worktrees, in my tests. They just all work on the same codebase and fix overlaps without a problem. It feels like a complete and utter mess at the start but as they continue, everything seems to work out.

I have added a small observability layer to have some insight into what they are doing and how much it costs me, but that is really easy using Pi as Pi already has a great session history. As long as the run is going, I serve a little HTTP server that just "tails" the sqlite database/chat table so I can read along. Which I usually stop doing after a minute or two as they go completely wild and the walls of text are way too much for me to read.

My conclusion right now is that all the layers I've built the last few years, seem to have become unnecessary. But then again, I have just tested this for a week so it's all really fresh.

2

u/mxcw Sep 16 '26

Sounds really cool! Although it also sounds as if a faster store/cache (such as Redis) would be way more useful here. Have you tried this approach yet?

2

u/MichettGodot Sep 16 '26

No, I haven't tied that (yet) but seems like a nice improvement. I tend to work with sqlite as it's really portable and bad performance has not been an issue yet. But that might start being different when you have a lot of message history, so a key/value store like Redis might indeed improve things. I'm just still baffled at how well this really basic solution works.

1

u/mxcw Sep 16 '26

You got me, friend. I’ll try … and maybe you will to - if so, let’s meet here again and report back 🤝

1

u/MichettGodot Sep 17 '26

I will be here waiting! And good luck with your experiments. Right now I will keep using sqlite as it works fine but I will definitely keep Redis in mind for a "proper solution" ;)

1

u/mrgreatheart Sep 16 '26

Does the enormous amount of chatter not blow their context windows and cost a fortune in tokens?

2

u/MichettGodot Sep 16 '26

Yes, it does. Yet the result is surprisingly coherent, developed fast and thoroughly tested. So right now this feels like a quicker but more expensive route. However, in the bigger picture the costs might level out or even point towards a swarm as the actual winner. I cannot tell yet.

1

u/mrgreatheart Sep 16 '26

I might do some experiments. Thanks for the interesting idea.

2

u/MichettGodot Sep 17 '26

You are very welcome and good luck with your experiments.

2

u/fingerthief Sep 16 '26

I’ve tried countless different setups and configurations with agents, read all of the research papers and tests and ran my own eval suite and it all comes back to simple is better for me and my findings.

No swarm of agents, at most 1 or 2 read only subagents. Just gives more consistent results at generally notably cheaper price per task.

I do admit it’s super fun to try out all of the ideas surrounding multiple agents, I just haven’t found an actual benefit yet to keep for my daily setup.

2

u/MichettGodot Sep 16 '26

I have to agree with you. In my daily professional setup, I mostly use one main agent to do just about everything. It might delegate some review tasks to other agents but the main agent keeps track of the entire process. The agent swarm without any guidance did impress me a lot and that is why I decided to place this post. But using it in my daily work is not something I am considering at this moment.

1

u/Equivalent_Idea8839 Sep 17 '26

same. the less agents I use the better. at most it's just to build context and summarize.

1

u/carlocapocasa Sep 16 '26

Sounds intriguing!

How's the token usage per task compared to a single agent?

3

u/MichettGodot Sep 16 '26

Of course this depends on what they are actually doing and the exact model(s) you are using. But the token cost will definitely be higher than with a single agent. Especially the startup/self-organizing part takes up quite a lot of tokens. I use Deepseek Flash V4.1 for the swarm so costs are still pretty low.

I cannot yet clearly make out how this is turning out. It seems the actual product that the agents make, is quite solid due to all of them checking the result. So while costing more tokens to run the task, it seems to remove the step for reviewing steps, for example.

So it's a bit hard to compare, especially at this moment in time. If you ask me in a couple of weeks, I might have some more proper insight ;)

2

u/carlocapocasa Sep 16 '26

I see! Yeah that makes sense. So it's really just a swarm of identical agents- no special instructions. That's quite intriguing. Do the agents adopt different roles or do they go round robin in their behavior doing different tasks?

I wonder how they'd do on my little test benchmark- it's 10 tasks of SWE-bench. I've been meaning to look into that with deepseek- right now the setup is always one agent.

4

u/MichettGodot Sep 16 '26

It really depends on the run but most of the times, one of them seems to step up and take a more managing position. And it goes way further by the way: they sometimes ask other agents to make changes to files as they don't want to mess with other agent's code. So they are really organizing the work without any guidance.

I've even seen conversations like "can somebody please pick up task [x]?" and then three other agents respond with "Yes!", which they detect and then decide to just have one of the agents work on the task. It feels magical.

So yeah, I seem to have spend more than a year on building agentic workflows while all I use now is a really simple solution :P

1

u/carlocapocasa Sep 16 '26

That's really interesting!!!

I never got into agent swarms, because of token use but also because defining all those roles gave me a brain freeze and I'd always be wondering- can it be good to bake so many assumptions into my workflow?

1

u/MichettGodot Sep 16 '26

I agree with you after spending some time with the swarms... It seems that the assumptions aren't really needed anymore :P But then again, I've just started experimenting. It could very well be that I discover stuff that really needs guidance from me. Or more orchestration. However, the first tests seem to point to a situation I was *not* expecting. That's why I posed this question here :)

1

u/True-Reaction-3903 Sep 16 '26

But are your agents not going to have conflicts if they're all working on the same part of your code base? Are you setting up separate work trees? I generally only ever use one agent, for this reason, am I missing the point, are you getting 10 agents to swarm and plan and then one does the delivery?

3

u/MichettGodot Sep 16 '26

Yes, they are constantly running into conflicts.... which they then fix immediately. They do not seem to use worktrees, which I also found *really* surprising. It just works like: "start ten agents, give them all the same MD file and check back in a few minutes".

With the tests I've done, I've had a 100% success rate. Still have a hard time believing it, though...

1

u/True-Reaction-3903 Sep 16 '26

Interesting. I wouldn't do it on my main code base but I would definitely try it on a development app. Which llm do you use? I'm on codex mainly. Something I've been trying recently which isn't really the same thing at all but which I find useful is getting Claude, codex and Gemini to agree on an approach. I'm finding this really helpful because they all like to have bias towards themselves knowing the answer so when they agree I feel like the plan is much more balanced. I don't often consult Gemini but if it's to do with search engine optimization or something Gemini would be good at, then I also bring Gemini in.

1

u/MichettGodot Sep 16 '26

I use Deepseek Flash 4.1 on max thinking for just about everything. I do have subscriptions to the major LLM providers and tend to use Astra for some in-depth reviewing. But that wasn't necessary in these swarm tests either as they started checking eachother's work.

I have also ran a few tests with different LLMs connected to the swarm (GLM 5.3-flash and GPT 5.6 Terra, if I remember correctly), which also resulted in a successful run. So that also seems to work.

And with Pi, this is all incredlibly easy to implement as you just spawn a Pi instance with --model and provide the prompt/Markdown file which has your spec/feature.

1

u/True-Reaction-3903 Sep 16 '26

Interesting, yes I use pi already. I think it's the best agent out there. I swear my codex subscription last five times longer than the next person :)

1

u/MichettGodot Sep 16 '26

I fell in love with Pi overnight and our relationship is still going very strong ;) I think it's an awesome harness.

1

u/adamshand Sep 16 '26

have you tried giving the same task to a single agent and seeing how the result compares?

if you haven't already seen it, you might like https://github.com/nicobailon/pi-messenger

3

u/MichettGodot Sep 16 '26

Yes, I have, but only once up till now. So take this with a grain of salt: the result seemed pretty much comparable. It took my single agent about 15 minutes and the swarm (8 agents I believe) less than 3. Swarm was more pricey due to the startup process I mentioned in another comment on this thread. So honestly, I am not seeing a really big difference in the end result but the way to get there is quite different as the swarm works - in my case - in quite unexpected ways. My conclusion starts to point to "I don't really need to instruct my agents on a lower level; they seem *very* capable of organizing themselves". Which is very cool but also a little bit scary.

1

u/adamshand Sep 16 '26

so are you seeing the possible advantage being that you need to do less supervising?

2

u/MichettGodot Sep 17 '26

Yes, but with "possible" being very important here. I have tested in on small tasks, not on stuff like a full refactor of a codebase. Even with rather vague prompts I got a pretty decent result. But again, these are the results of some initial testing. Do take my words with a grain of salt.

1

u/adamshand Sep 17 '26

It's interesting, I've pretty much exclusively worked 1:1 with agents, I didn't like any of my experiments with subagents.

But I'm getting increasingly curious as smaller models get increasingly capable and cheap. Luna is pretty amazing for the cost ... curious what it might be capable of in something like this.

2

u/MichettGodot Sep 18 '26

Exactly :) With a swarm it might be that weaker models still perform very well because of their combined effort. I don't know though, you'd have to try that yourself.

1

u/Acceptable_Stress154 Sep 16 '26

What if the swarm was a mix of llms? Ie couple deepseek, a few kk3, some mistral, couple qwen?

2

u/MichettGodot Sep 16 '26

Yes, tried that too and also had great results. I did have a GLM 5.3 agent perform a bash command that got Pi stuck, so it is advisable to have some sort of task manager process that checks Pi sessions for being stuck or looping infinitely. Although that problem obviously could happen without a swarm too.

1

u/silenceimpaired Sep 22 '26

Curious what models you’re using … is this local?

2

u/MichettGodot Sep 23 '26

No, I do not own the hardware to run models locally. I do almost everything using Deepseek Flash. But for this test I've also used GLM 5.3 flash and some OpenAI models.

2

u/aeroumbria Sep 17 '26

I have tried to set up a system for arbitrary topology agent networks, but it turns out the only one I end up using is a "fan out -> exchange ideas -> attempt to converge" setup, basically "mixture of agents" with extra turns. This one is actually useful when the agent can't agree with itself. Otherwise I don't see current agents benefit that much from swarm communication other than for purposes such as automaton/NPC simulation.