Inspiration

The challenge asked for agents that keep working when communication fails. A central dispatcher would have dodged that, because if the dispatcher goes down, everything stops. So we built a system with no manager at all.

What it does

A team of identical AI agents finds and patches security holes across several web servers. They never talk to each other. They coordinate through a shared board of tickets, and if one agent dies mid-job, another picks up its work automatically.

How we built it

The architecture has four primary components:

  • Agent Shared state (Redis): Each vulnerability has a ticket key with its status (open, in progress, fixed) and a log of failed attempts. A separate lock key marks which agent is working on it.

  • Agents (Python): Every agent runs the same loop. To claim a ticket it does an atomic SET NX on the lock key with a 90 second expiry, so only one agent can win. While working, it renews the lock every 30 seconds. Writes to the ticket go through a Lua script that checks the agent still holds the lock, so an agent that lost its claim can’t overwrite someone else’s work.

  • Target servers. Three containers running a small PHP site with three planted vulnerabilities we wrote ourselves: SQL injection, reflected XSS and an unsafe file upload. Each has an exploit script that reports vulnerable, patched or broken.

  • User Dashboard: A Flask page that only reads Redis and shows every ticket’s status and diff.

  • Failure remediation: If a dead agent stops renewing its lease, Redis deletes the lock after the timeout, and the ticket becomes claimable again. There is no code that detects failures. The patches come from qwen2.5:7b running locally through Ollama. After two failed attempts on a ticket, the next agent gets a stronger prompt that includes the earlier failures.

We also added an approval step using an n8n workflow. Agents stage a verified patch and wait for a human, or an automated n8n workflow, to approve it before it goes live.

Challenges we ran into

Making sure two agents never worked on the same job, and that an agent that crashed mid-task couldn’t leave things half-done or overwrite someone else’s work. We also had to make sure “fixed” really meant fixed, by testing against the live site rather than trusting the AI’s output.

Accomplishments that we’re proud of

  • You can kill agents mid-patch and the rest will re-claim the ticket and still finish the job.
  • Completely got rid of the need for a dispatch manager!

What we learned

A shared board with expiring locks was enough to replace a manager entirely. Recovery came from the design, not from extra code.

What’s next for PHPirates Swarm

Letting agents keep coordinating peer-to-peer if the shared board goes offline, and adding more vulnerability types.

Built With

Share this project:

Updates

Submission history