Reducing Token Usage of State-in-Context Agents using Minification
This paper presents a replication of the state-in-context agent framework and demonstrates that applying code minification techniques reduces input token usage by 42% at the cost of a 12 percentage-point drop in resolution rate, offering a promising trade-off for more cost-effective software engineering agents.
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 hiring a brilliant but very expensive consultant to fix a broken machine. The machine is a massive, complex software program (a codebase), and the consultant is an AI.
Every time the AI reads a piece of the manual or a page of the machine's blueprint, it costs money. The more pages it has to read, the higher the bill.
The Problem: Too Much Paperwork
The researchers found that when these AI agents try to fix software bugs, they are drowning in paperwork. They spend most of their time reading the actual code—the "blueprints"—which takes up about 90% of the total cost. The instructions and the list of which files to look at are tiny by comparison.
It's like hiring a detective to solve a crime, but you force them to read the entire phone book of the city before they can even look at the crime scene. They get tired, the bill gets huge, and they might miss the clue because they are overwhelmed by the sheer volume of text.
The Solution: "Minification" (The Shrink Ray)
The paper introduces a technique called Minification. Think of this as a "Shrink Ray" for code.
In the world of software, code often has extra spaces, comments (notes for humans), and long variable names like calculate_total_revenue_for_the_month. These are great for humans to read, but they are just "fluff" for a computer.
The researchers applied a series of transformations to "shrink" this code before sending it to the AI:
- Remove the Fluff: They stripped out blank lines, comments, and documentation.
- Tighten the Squeeze: They removed extra spaces around math symbols (turning
a + bintoa+b). - Shorten Names: They renamed long variables to short ones (turning
calculate_total_revenue_for_the_monthintox).- Crucial Detail: To make sure the AI didn't get confused, they provided a "translation dictionary" so the AI knew that
xactually meantcalculate_total_revenue_for_the_month.
- Crucial Detail: To make sure the AI didn't get confused, they provided a "translation dictionary" so the AI knew that
The Experiment: Does the Shrink Ray Work?
The team tested this on a famous benchmark called SWE-bench, which is like a standardized test of 100 real-world software bugs. They used a powerful AI model (GPT-5-mini) to try and fix these bugs.
The Results:
- The Good News: The "Shrink Ray" worked incredibly well at saving money. It reduced the amount of text the AI had to read by 42%. This is a massive reduction in cost.
- The Bad News: The AI got a little worse at solving the problems. The success rate dropped by 12 percentage points (from 50% success down to 38%).
The Trade-off:
The paper concludes that you can save a lot of money by shrinking the code, but you have to accept that the AI will solve fewer problems. It's a trade-off between efficiency (cost) and effectiveness (success).
One Big Warning: The "Indentation" Trap
There was one specific type of shrinking that caused a lot of trouble: Dedentation.
Python code (a popular programming language) relies on indentation (spaces at the start of a line) to know how to group instructions. The researchers tried to reduce the number of spaces to save tokens.
- What happened: The AI got confused. It would write a fix that looked correct to the AI but was actually broken code because the spacing was wrong.
- The Analogy: It's like telling a chef to "chop the onions" but removing the instruction on how to hold the knife. The chef tries, but the result is a mess.
- The Fix: The paper suggests that if you want to use this method, you need a "safety net" to fix the spacing automatically after the AI writes its answer. Without this, the success rate crashes.
Summary
The paper shows that we can make AI software engineers much cheaper by stripping their "reading material" down to the bare essentials.
- Cost: Drops significantly (42% less text to read).
- Performance: Drops moderately (12% fewer bugs fixed).
- Caveat: You have to be careful not to remove the "grammar" (indentation) that the code needs to make sense.
The researchers made their tools available on GitHub, allowing others to try this "Shrink Ray" on their own software projects.
Drowning in papers in your field?
Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.