Inspiration
Most "AI code review" tools give you one model's single opinion, and that bothered me as someone working in security. The interesting part of security isn't a one-shot verdict; it's the back-and-forth. An attacker probes, a defender responds, and the attacker retests the patch. I wanted to build a system that captures that adversarial loop instead of a single pass.
What it does
PurpleForge hardens source code through AI self-play. You give it a file, and three specialised agents work the problem from opposing angles:
-Red- attacks the code and reports each vulnerability with its CWE classification, location, and impact. -Blue patches the findings with behaviour-preserving fixes. -Judge scores each round measuring both how many findings were resolved and whether the patch introduced regressions and decides when the code has converged to a hardened state.
Then it loops. Every round, Red re-tests its own prior findings to confirm the fixes actually hold, so a patch is only accepted once it survives re-attack. You watch a hardening score climb in real time, and you walk away with two things: the hardened source code, and a CWE-referenced security report you could attach straight to a pull request.
How I built it
The backend is a *FastAPI service that runs the Red → Blue → Judge loop, with structured-JSON contracts between agents and a convergence rule. It streams the round-by-round battle to the browser live over Server-Sent Events, and persists run history to SQLite.
Models run on Qwen Cloud via its OpenAI-compatible API. I split models by role deliberately: qwen3.7-plus powers the high-frequency Red and Blue agents (they run every round), while the flagship qwen3.7-max acts as the Judge. The whole backend is deployon Alibaba Cloud (ECS) ,running as a managed service.
Challenges I ran into
- Blue "winning" by breaking things. Early on, the defender would sometimes delete functionality to make findings disappear. I solved this by having the Judge explicitly score regression risk, so a fix that breaks behavior gets penalized.
- Reliable structured output. Agents needed to hand structured data to each other, so I built a defensive JSON parser that tolerates code fences and stray prose.
- False-positive churn. Red is instructed to prefer a few true findings over many speculative ones and to re-test prior findings each round rather than re-litigate them.
What I learned
In multi-agent systems, you get the behaviour you score for. The judge's scoring rubric shaped the whole system's quality more than any single prompt. I also learned how clean Qwen Cloud's OpenAI-compatible API makes it to orchestrate multiple models with different roles.
What's next
- Feed Blue's patch through the target project's real test suite as a hard regression signal.
- Whole-repository, dependency-aware analysis instead of single files.
- A sandboxed reachability check that confirms a finding is exploitable before patching.
- SARIF output for CI/CD integration.
Track: Agent Society multiple agents with distinct roles dividing the task, negotiating through an adversarial loop, and measurably outperforming a single-agent pass.
Log in or sign up for Devpost to join the conversation.