An LLM Agentic Approach for Legal-Critical Software: A Case Study for Tax Prep Software
This paper proposes an agentic LLM framework that automates the translation of U.S. tax code into executable software and utilizes higher-order metamorphic relations for test generation, demonstrating that a smaller model (GPT-4o-mini) outperforms frontier models in achieving robust, trustworthy legal-critical software.
Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer
Imagine you are trying to build a robot that can do your taxes. This isn't just any robot; it's a robot that has to follow the law exactly. If it makes a tiny mistake, you could get audited, fined, or miss out on money you deserve.
The problem is that tax laws are written in "Legalese"—a confusing, ambiguous language full of exceptions, edge cases, and constant updates. If you ask a standard AI (a Large Language Model or LLM) to just "write the code for the tax law," it often hallucinates (makes things up) or gets the logic wrong, like applying a tax rate to the wrong part of your income.
This paper introduces a new way to build this "Tax Robot" called Synedrion. Instead of asking one super-smart AI to do everything, they built a team of specialized AI agents that work together like a human software company.
Here is the breakdown using simple analogies:
1. The Problem: The "Oracle" Mystery
In normal software testing, you know the answer before you start. If you ask a calculator 2 + 2, you know the answer is 4. This is called an "Oracle."
But in tax software, nobody knows the exact answer beforehand without a human expert looking at the law. If a single person earns $50,000, is the tax $7,200 or $7,250? It depends on a dozen tiny rules. This is the "Oracle Problem." You can't just check if the robot is right because you don't know the right answer yourself.
2. The Solution: The "Synedrion" Team
The authors created a team of AI agents, each with a specific job, mimicking a real-world law firm and engineering team:
- The Tax Expert (The Translator):
- Analogy: Imagine a strict lawyer who reads the messy tax code and turns it into a clean, structured recipe card (JSON format).
- Job: They don't write code; they just translate the confusing laws into clear, step-by-step instructions that a computer can understand.
- The Coders (The Builders):
- Analogy: These are the construction workers. They take the "recipe card" from the Tax Expert and build the actual software.
- Job: They write the Python code. There are two of them: one builds the first draft, and a "Senior Coder" (a manager) reviews it. If the draft is messy, the manager sends it back for fixes.
- The Metamorphic Agent (The Quality Inspector):
- Analogy: This is the most creative part. Imagine a detective who doesn't know the exact answer to a math problem, but knows the rules of the game.
- Job: Instead of asking "Is the tax $7,200?", this agent asks: "If I give the robot a person with more income, should the tax go up?" or "If I make someone blind, should their tax go down?"
- The "Higher-Order" Twist: The paper's big innovation is that this agent doesn't just check simple "up or down" rules. It checks rates of change.
- Simple check: "If income goes up, tax goes up." (A bad robot that charges a flat 20% on everything passes this).
- Higher-Order check: "If income goes from $40k to $41k, the tax should jump slightly because you crossed a bracket. But if it goes from $41k to $42k, the jump should be bigger."
- This catches "flat-rate" bugs that simple checks miss.
3. The Surprise: Small Dogs vs. Big Lions
Usually, in AI, bigger models (like GPT-4o or Claude-3.5) are smarter than smaller ones. You'd expect the "Big Lion" to win.
The paper found the opposite:
When using this team approach, a smaller, cheaper AI model (GPT-4o-mini) actually performed better than the massive, expensive models when working alone.
- Why? The massive models tried to do everything at once and got confused by the complexity. The smaller model, when guided by the "Tax Expert" and checked by the "Inspector," stayed focused and made fewer mistakes. It's like a small, focused apprentice with a great mentor doing better than a distracted genius.
4. The Results: Catching the "Flat Rate" Trap
The team tested their system on six different tax scenarios, from simple deductions to complex retirement distributions.
- Without the team: Even the best AI models failed on the hardest tasks (getting less than 15% of the answers right).
- With the team: The smaller model, guided by the agents, got 45% to 88% of the answers right (depending on the complexity).
- The "Inspector" effect: Adding the "Metamorphic Agent" (the detective) was crucial. It found systematic errors that the builders missed, pushing the success rate even higher.
Summary
This paper argues that to build software for critical legal tasks (like taxes), we shouldn't just ask a super-intelligent AI to "do it." Instead, we should build a collaborative team:
- One to translate the law.
- One to build the code.
- One to act as a detective, checking if the logic holds up under pressure.
By using this "Agentic" approach, even smaller, cheaper AI models can build software that is safer, more accurate, and more trustworthy than the most powerful models working alone. It turns the chaotic process of coding from legal text into a structured, reliable assembly line.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.