Inspiration
Most AI legal assistants act like a single expert: you describe a dispute, and one model gives you an answer. We felt that was the wrong shape for legal reasoning, because real courts do not work as solo intelligence systems, they work through adversarial collaboration, scrutiny, objections, testimony, and independent deliberation.
That led to the core idea behind Codex Legalist: instead of asking one AI for a legal opinion, what if we simulated an entire courtroom using a society of specialized Qwen agents? Since this hackathon’s Agent Society track is about role-based collaboration and negotiation, the courtroom became a natural environment to test whether structured multi-agent reasoning could outperform a single-agent response.
What it does
Codex Legalist is an autonomous courtroom simulation powered by Qwen Cloud. A user submits a dispute through case facts, documents, or audio evidence, and the system turns that input into a full courtroom proceeding rather than a one-shot answer.
Instead of one model doing everything, the system distributes legal work across 11 specialized agents: Magistrate, Judge, Prosecutor, Defence Counsel, Witnesses, Fact Checker, Clerk, Jury Foreperson, Jury Panel, Shadow Juries, and Archivist. Each role is narrowly scoped so legal reasoning emerges through structured debate, witness examination, objections, jury deliberation, and independent review.
The final output is not just a verdict. It includes evidence-based arguments, courtroom transcripts, witness examination, jury reasoning, and a confidence score produced through Shadow Jury consensus rather than a single model’s guess.
How we built it
The backend is built with FastAPI, and the orchestration layer uses LangGraph as a state machine to move each case through realistic trial phases. The system routes the trial through stages such as security check, magistrate review, discovery, opening statements, evidence presentation, witness examination, rebuttal, closing arguments, jury instructions, jury deliberation, Shadow Jury evaluation, and final verdict generation.
All reasoning runs on Qwen Cloud through Alibaba Cloud DashScope, with different Qwen models assigned to different courtroom roles based on task complexity and speed requirements. The architecture also supports file parsing, audio transcription with Qwen audio models, a live transcript-style frontend, and verdict visualization.
Challenges we ran into
The hardest part was not generating legal text, but coordinating many agents without letting them drift, repeat themselves, or break courtroom procedure. We had to define clear role boundaries, routing logic, and summarization behavior so that each participant stayed useful inside a long-running adversarial process.
A second major challenge was balancing realism with performance. Our benchmark showed that the multi-agent approach is slower than a raw LLM or single-agent flow, but it produces more evidence citations, fewer hallucinations, and more consistent outcomes, which is the trade-off we wanted for legal analysis.
Accomplishments that we're proud of
We are proud that Codex Legalist goes beyond a chatbot and functions as a full adversarial AI courtroom.
Another major accomplishment was showing that the multi-agent approach produced measurable quality gains over simpler baselines
Finally, we are proud that the system is not limited to one narrow legal setting. Codex Legalist supports 16 jurisdictions across common law, civil law, and mixed systems, adapting courtroom procedure, standards of proof, evidence rules, and jury behavior to the selected legal environment.
What we learned
The biggest lesson from Codex Legalist is that complex reasoning improves when responsibility is distributed instead of centralized. Compared with a single-agent approach, specialized Qwen agents produced clearer evidence tracking, stronger debate structure, and more explainable verdicts.
We also learned that agent societies only work when orchestration is strict. Role clarity, verification layers, and procedural constraints mattered just as much as model capability.
What's next for Codex Legalist
Next, we want to add retrieval-augmented legal research over statutes and case law, expand jurisdiction coverage, support larger multimedia evidence collections, and enable collaboration between human lawyers and AI courtroom participants. Those additions would make Codex Legalist more useful not only as a legal assistant, but also as a training and education system.
Log in or sign up for Devpost to join the conversation.