The Cost of Abstraction for Humans and AI Agents
GitHub Pages
More code abstraction can make AI coding agents costlier. One test found over-abstracted code pushed agent bills up by an estimated 30%.
Based on reporting by GitHub Pages — read the original for the full story.
Summary, retelling and take written by AI under human oversight; images are AI-generated illustrations. How we work · Report an error
A frontend developer has spent a lot of time unlearning a habit many mid-level engineers pick up: reaching for abstraction too early. The argument here is simple and annoyingly plausible. Abstraction is useful when it hides complexity, gives something a name, or makes reuse worthwhile. But when it’s just another layer between the reader and the code, it starts charging rent.
That rent shows up in human time first. More indirection means more jumping between files, more names to remember, and more context to hold in your head. The piece uses a small example: a delete button spread across six files, just to answer a simple question about its color. That kind of setup is manageable when you know the codebase. It’s a lot less charming when you’re new, or when you’re in a hurry, or both.
The more surprising claim is that AI agents pay the same tax, and often more of it. Since agents are trained on human code, they inherit our love of layers, factories, wrappers, and neat little boundaries. To test that, the author built two feature-matched calculator apps in Vite, React, and Tailwind: one mostly collocated, one with 12 extra abstraction layers. On the task of changing the = button color, the over-abstracted version cost 5x more in both money and time. The result was repeated 10 times to get past random noise.
Then came the attempt to separate size from structure. The author compared versions that were both around 2,000 lines and around 3,500 lines. Even when size was controlled, the abstracted code still came out about 3x more expensive on that task, with 2.2x more agent round trips. Across seven tasks, the gap ranged from 0.8x to 5x. Some tasks even favored the abstracted version, especially when a well-named abstraction acted like an index. But the expensive cases were the ones that crossed file boundaries.
After 394 agent runs and an extra model used to extrapolate the results, the author settles on a conservative estimate: over-abstraction raises AI agent costs by about 30% in a real mid-to-large codebase. The neat part is not that abstraction is bad. It’s that the bill now makes the old code smell visible in a way teams can’t shrug off as easily.
My take — AI-written commentary, not fact-checked reporting
This is the kind of paper-cut that turns into a budget line item and, finally, into discipline. Teams love abstraction because it feels senior; agents expose the invoice because they pay for every little hop. The funny part is that the industry spent years teaching people to hide complexity, and now the machines are politely asking why the closet has six doors.
Read more about this at: GitHub Pages