New Theory Proposes Software Thermodynamics for Coding Agents
Researchers have introduced a theory of software thermodynamics to analyze the token efficiency of coding agents, distinguishing work from wasted heat.
Source: Grafy Research LabResearchers have introduced a theoretical framework called software thermodynamics to quantify the efficiency of AI coding agents. By drawing parallels to classical and stochastic physics, the study aims to explain what a developer actually receives for the tokens they pay for when using agentic tools.
How does software thermodynamics work?
According to the research by Alán Aspuru-Guzik and Varinia Bernales, the theory treats a code repository as a system and the tokens generated by an AI agent as its cost. The researchers propose dividing this total token cost into two distinct categories: work and heat.
In this framework, "work" represents the tokens that directly contribute to the intended code change, while "heat" refers to the tokens spent on auxiliary tasks such as reading files, searching the repository, and running tests. To test this, the authors used a cycle analogous to molecular biology experiments: an agent makes a specific change to a repository (coding) and then subsequently reverses that change (uncoding). By measuring the tokens consumed in both directions, they can estimate the "free energy" of a change, which represents the minimum theoretical cost required to achieve the edit.
What are the efficiency findings?
Experimental results suggest that current agentic coding processes are significantly inefficient in terms of token consumption. The authors report that for a successful coding run, approximately 80 percent of the tokens generated are actually "heat."
Specifically, in a test case involving a module renaming task at a Hinton temperature of 0.5, the mean cost was 2,305 tokens. Of these, 1,890 tokens were classified as heat, while only 415 were classified as work. The estimated free energy—the most efficient possible cost for the change—was calculated to be approximately 351 tokens. This implies that the vast majority of the token budget is spent on the process of reasoning and verification rather than the final code output itself. Furthermore, the study found that coding is more expensive than uncoding, with coding costs ranging from 1.1 to 1.5 times higher than the cost of undoing the same change.
What is the role of the test suite?
The researchers describe the test suite as a "software Maxwell's daemon." In physics, Maxwell's daemon is a thought experiment involving a gatekeeper that sorts molecules; in this software context, the test suite acts as a gatekeeper that judges every coding change, allowing only those that pass to "land" in the repository.
However, the authors note that this daemon is imperfect. A test suite that contains errors or is insufficiently rigorous can allow broken changes to pass through. When a gate errs, it results in a cost in tokens, either through wasted effort on sound changes or through the consequences of "false landings" where broken code is accepted. The research suggests that the "temperature" of the gate—its error rate—rises as the difficulty of the task increases.
Why does this matter for developers?
As AI agents become more integrated into software engineering workflows, understanding the distinction between productive tokens and wasted tokens becomes critical for cost management and tool optimization. The theory provides a mathematical basis for analyzing whether an agent is stuck in a loop or if the overhead of the "harness" (the environment the agent operates in) is disproportionately high.
By treating the test suite as a scientific instrument rather than just a pass/fail mechanism, developers can better calibrate the balance between agent autonomy and safety. The paper concludes with several practical recommendations, such as avoiding sampling models at extremely "cold" temperatures where agents may fail to land, and reporting the cost of runs as both work and heat to provide a clearer picture of efficiency.
Applying these insights to coding
For developers looking to experiment with agentic workflows, understanding the balance between prompt complexity and code output is essential. While this research provides a theoretical lens for efficiency, you can observe agentic behavior in practice using Grafy Code, which provides a workspace for running and testing AI-generated code. For those looking to dive deeper into the specific academic papers mentioned in such studies, Grafy Reader can assist in analyzing complex research PDFs and extracting key findings.
Frequently asked questions
What is the difference between work and heat in this theory?
In the context of software thermodynamics, work refers to the tokens used to produce the actual code changes requested by the user. Heat refers to the tokens spent on non-productive activities required to reach that state, such as searching through files, reading documentation, or performing repetitive testing cycles that do not result in the final code edit.
Does coding cost more than uncoding?
Yes, according to the researchers, coding is more expensive than the process of undoing a change. Their tests indicated that the cost of making a change to a repository is between 1.1 and 1.5 times higher than the cost of an agent performing the uncoding process to return the repository to its original state.
How much of an agent's cost is considered heat?
In the experimental runs conducted by the authors, approximately 80 percent of the tokens used in a successful coding run were categorized as heat. This means that the majority of the token expenditure in current agentic coding setups is dedicated to the surrounding processes of reasoning and verification rather than the direct generation of the code itself.
Source: Grafy Research Lab — Where the Tokens Go: Heat, Entropy and Error in Agentic Coding


