BlogEngineering

Start With Intelligence, Compile It Away

Part 2 of Simple Control Flow, Intelligent Decisions: how an agentic harness turns repeated reasoning into fast, reusable code.

3 min read Isotopes AI

In Part 1, I argued that agentic software inverts traditional architecture. Keep the state machine small. Put the intelligence in the transitions.

That design is flexible. It is also expensive.

The cost of thinking twice

In our harness, every agent, whatever its specialty, is a coding agent. It writes code, executes it, verifies the result, and corrects course. That loop handles problems nobody programmed for, and it is slow.

Take a real case from our harness: scheduling a clinical trial. It is a hard optimization problem, dense with interacting constraints. The first time, a coding agent had to reason its way to a working approach. It modeled the constraints and worked through a long optimization loop: code, test, fix, test, fix again. That was money well spent. But the same kind of scheduling request kept coming back. Each time, the agent reconstructed the solution from scratch, consuming over 100 million tokens across its reasoning, coding, and correction cycles.

Rebuilding the same reasoning on every run is amnesia, and amnesia is expensive.

System 2 writes System 1

So we built a System 1 / System 2-inspired harness, borrowing Kahneman’s split between slow deliberation and fast, automatic response.

System 2 is our general coding agents. They take anything new, ambiguous, or hard.

System 1 is a growing library of reflex agents: specialized agents made almost entirely of static code, each doing one familiar job in a fraction of the time and cost. System 1 is mostly code, rather than a smaller, faster model.

System 2 writes them. Every System 2 run already produces code, so the raw material for a reflex is a byproduct of ordinary work. No separate language for reusable skills is needed. When the system recognizes that the same class of problem keeps getting solved the same way, System 2 extracts the general method, parameterizes what varies, and produces a candidate reflex. Once validated across the problem class, it joins System 1. The trial scheduler became one of the first. Now, scheduling requests within its validated operating range skip that 100-million-token cycle entirely.

A cached answer would be useless here, because every trial is different. What gets compiled is the method: how to formulate this class of problem and solve it. Each new trial still gets a fresh schedule. The harness just no longer has to rediscover how to build one.

Reflexes take over repeated execution. The judgment about when to use one stays with intelligence.

A JIT for reasoning

The closest analogy is a JIT compiler. A JIT compiles hot paths and, when an assumption breaks, deoptimizes back to the general interpreter. Here, System 2 is the interpreter and reflexes are the compiled hot paths.

But a reflex is distilled from past reasoning, and past reasoning can be wrong. Repetition tells the harness what is worth compiling. Verification establishes what it can safely reuse.

The foreground loop solves problems. A slower optimization loop watches how they get solved and turns recurring successful work into reusable capabilities.

Unlike a conventional JIT, though, the guard on a reflex may itself require sophisticated reasoning.

Two hard problems

Dispatch is the ultimate sophisticated conditional. Is this input the pattern the reflex was built for, or something that only looks like it? This is Part 1’s inversion again: a two-way branch guarded by a demanding judgment.

Don’t optimize dispatch at the expense of judgment. A frontier model making the call costs little next to the System 2 cycle it saves, while a bad dispatch can route work through the wrong reflex. The cheapest path through the system sits behind the smartest decision in it.

Reflexes rot. A reflex that was right in March can be quietly, confidently wrong by September. So reflexes need validation suites, drift monitoring, and a way to retire them.

Software that needs less intelligence over time

Over time, the harness turns expensive cognition into cheap computation. That reverses an assumption as old as software. We have always started with deterministic code and reached for intelligence only where explicit programming broke down. Now we can run the other way. We can begin with intelligence, let it meet the real world, watch what it does again and again, and steadily, deliberately harden the repeated parts into software, until the models are left with only the work that truly needs a mind.

Part 1 was about how to organize intelligence. This one is about how to amortize it. One line joins them:

Keep intelligence in control. Compile intelligence out of execution.

And the full philosophy:

Keep control flow simple. Put intelligence in the transitions. Decompose reasoning carefully. And when reasoning becomes repeatable, compile it away.

Next: Dreamtime. How NeoCortex learns from an agentic system’s accumulated experience, and decides which intelligence should become software.

Next step

See aidnn on your messiest data.

A live walkthrough on your own workflows. Connected in minutes, not months.

Agent view · /blog/start-with-intelligence-compile-it-away.mdllms.txt

Colorcurrent
Tone
Mode