Skip to content

Maxwell's Demon

In 1867, James Clerk Maxwell imagined a creature.

It sits by a tiny door in a partition dividing a gas container. It can tell fast molecules from slow ones. Fast ones go left, slow ones go right. No work performed, yet heat flows spontaneously from cold to hot. The second law, defeated.

Or so it seemed.

The thought experiment has outlived Maxwell by more than a century and a half. It persists not because it is clever, but because it encodes a structural fact: information and physical order have an exchange rate.

That fact happens to be an exact description of what harness engineers do every day.

What the Demon does

The setup, stated precisely.

An insulated container. A partition in the middle. A door in the partition. Gas molecules bounce around on both sides. The Demon watches each molecule that approaches the door. Slow molecule on the left side? Open the door, let it through to the right. Fast molecule on the right? Open the door, let it through to the left. Otherwise, keep the door shut.

After enough rounds, the left side holds only fast molecules (high temperature), the right side only slow ones (low temperature). A uniform-temperature system has been sorted into a hot half and a cold half. Entropy has decreased.

No work was done. The door is massless; opening and closing it costs effectively nothing. The second law says entropy in an isolated system can only increase or stay the same. The Demon appears to violate it.

This paradox stood unresolved for over a hundred years.

Information is not free

The answer arrived in two stages.

In 1961, Rolf Landauer at IBM made a claim that looked modest at first: erasing one bit of information produces at least \(kT \ln 2\) of heat. This is not an engineering limitation. It is a physical law. Destroying information is an irreversible physical process, and irreversible processes necessarily generate entropy.

In 1982, Charles Bennett connected Landauer's principle back to Maxwell's Demon. To sort molecules, the Demon must complete a full information-processing cycle:

  1. Measure: observe a molecule's velocity, acquiring information.
  2. Decide: based on that velocity, open or keep shut.
  3. Store: record the decision (without memory, it cannot sustain operations).
  4. Erase: when storage fills up, clear old records to make room.

Steps 1 through 3 can, in principle, be designed as thermodynamically reversible, generating no extra entropy. Step 4 cannot. Landauer's principle is unambiguous: erasure is irreversible. Every bit of cleared memory dumps at least \(kT \ln 2\) of heat into the environment.

The Demon reduces entropy inside the container, but increases entropy in itself and the environment through information erasure. When you settle the full account, the second law holds -- not a scratch on it.

Order does not appear from nothing. The cost of sorting is hidden in the final step of information processing.

A frontier debate

Earman & Norton have long questioned the sufficiency of the Landauer-Bennett resolution, and a 2025 paper (arXiv:2503.18186) further argues that measurement, not erasure, is the step where entropy is truly generated. The debate remains open. But regardless of which step carries the cost, the core conclusion is untouched: sorting information cannot be free. The only question is which line item the bill lands on.

The mapping

What a harness engineer does and what the Demon does are structurally the same operation. The correspondence is tighter than metaphor: it is a structural mapping.

Demon's world Harness engineer's world
Gas molecules Tokens, tool outputs, external data
Distinguishing fast from slow Filtering, validation, routing
Opening / closing the door Selectively injecting or blocking information into the context window
Storing records The context window itself
Erasing old records Compaction, summarization

The Demon sorts molecules to reduce thermodynamic entropy in the container. The harness engineer sorts information to reduce information entropy in the system, keeping the context window high-signal and low-noise, making the agent's next action as deterministic and correct as possible.

This is not a coincidence of analogy. Return to the framework from the first article in this chapter: information entropy and thermodynamic entropy share the same mathematical skeleton. On that skeleton, the Demon's operations and the harness engineer's operations occupy isomorphic positions.

And isomorphism means the constraints are isomorphic too.

The cost of sorting

Landauer's principle exacts its toll in heat. In agent systems, the toll takes different forms, but the structure is identical: every operation that reduces information entropy carries an irreducible cost.

To be clear: the mapping is structural, at the information-theoretic level. Compaction does not literally generate heat. In the physical world, the cost is thermal dissipation. In agent systems, it is information loss, computational expense, and complexity growth. Different currencies, same ledger.

Start with compaction. Compressing conversation history inevitably discards detail. Factory's research, tested across more than 36,000 real development session messages, surfaced a stark number: every compression scheme scored only 2.19 to 2.45 out of 5.0 on artifact tracking (the ability to maintain awareness of file changes). No matter how carefully you design a structured summary, compression loses things. If those lost details are needed later, the agent must re-acquire them, and the tokens saved may not cover the bill for re-acquisition.

Validation has its own bill: latency and tokens. Every check on a tool's output, every verification of an LLM's response, consumes compute and time. Stricter validation means a bigger bill.

Routing pays in complexity. Dispatching tasks to different subsystems or sub-agents requires routing logic, edge case handling, state synchronization. Every additional layer of sorting adds a layer of cognitive overhead to the system.

None of these costs indicate poor implementation. They are structural. The Demon cannot reduce entropy in the container without increasing entropy in the environment. A harness engineer cannot maintain system order without paying a price.

There is no free order maintenance.

The entropy control philosophy

This chapter has followed a single thread. It started with the mess on your desk, passed through Boltzmann's microstate counting, Shannon's information measure, the dual identity of the temperature parameter, and arrived here -- at Maxwell's small creature and the information cost it cannot escape. All of it points at the same conclusion.

Entropy increase is the default direction. Opposing it requires a cost. That cost is irreducible. You can manage it. You cannot eliminate it.

This is the entire philosophy of entropy control: not the pursuit of zero entropy, but the search for the optimal operating point under the constraint of entropy increase.

Zero entropy is an illusion. An agent system that chases "never wrong," "context never degrades," "information never lost" will watch its costs balloon past any reasonable budget. Infinite validation layers, infinite context windows, infinite redundancy. It is the equivalent of keeping your desk in first-day condition while actively using it: theoretically possible, practically meaning you spend all your time tidying and none working.

But abandoning order is not an option either. An agent system that does no information sorting -- no compaction, no output validation, no noise filtering -- loses coherence rapidly under entropy increase. The research on context rot has quantified this: even with very large context windows, accumulated information itself degrades model performance.

The optimal operating point sits somewhere between those extremes. It depends on task characteristics, model capability, acceptable failure rates, tolerable latency, and budget. It is not a fixed point. It is a balance that requires continuous adjustment.

Entropy control is not a technique, a framework, or a checklist. It is a design philosophy: acknowledge that costs exist, then make choices within the constraints.

The Demon cannot abolish the second law of thermodynamics. What it can do is understand where the costs lie, and decide whether each bill is worth paying.


If entropy control is the philosophy, then applying it across an agent system's full lifecycle (from context curation to error recovery to long-running operation) demands something beyond a single Demon's intuition. It demands a systematic engineering methodology.


Further reading

  • Landauer, R. (1961). "Irreversibility and Heat Generation in the Computing Process." IBM Journal of Research and Development, 5(3).
  • Bennett, C.H. (1982). "The Thermodynamics of Computation -- A Review." International Journal of Theoretical Physics, 21(12).
  • Factory.ai (2025). "Evaluating Context Compression for AI Agents."