Mindlap

Loop Engineering Is Harness Engineering

A great harness doesn’t just let an agent try and fail. It helps the agent understand the failure, recover, and keep going. That’s a loop.

Mindlap
Abhinav Palash·7 min read·July 15, 2026

We’ve started debating “loop engineering” versus “harness engineering.”

To me, they’re the same idea.

Both describe the software around an agent. The software gives the agent context and tools. It tracks progress. It checks the work. It helps the agent recover. It keeps the process moving until the job is done.

A great harness does not merely let an agent try and fail. It helps the agent understand the failure, recover, and keep going.

That is a loop.

Why “loop” is a useful word

I prefer “harness engineering” as a term. But “loop engineering” evokes an interesting intuition.

It makes me think of an automaton.

We deal with these systems every day: operating systems, software installers, regular expression engines, vending machines.

They all move through states. Inputs cause work to happen. The result determines what happens next.

This is a useful way to think about long-running agents.

A state machine can be described with five things:

  • States
  • Inputs
  • Transitions
  • An initial state
  • Final states

The machine starts somewhere. It receives input. It performs work. It moves between states — sometimes forward, sometimes back to an earlier state. It stops when it reaches a final condition.

The state can contain more than a label. It can include the current plan, accumulated context, produced artifacts, previous attempts, and remaining budget.

The operation inside a state may be stochastic because an AI model is doing the work. The machine around it is still ordinary software.

An agent state machine showing states, transitions, and failure recovery paths

An agent is a state machine with stochastic workers

Consider a software engineering agent.

It may move through these states: Define work → Write code → Verify → Merge.

Each state requires inputs. The coding state needs a clear task, a repository, constraints, and relevant context. The verification state needs the resulting code and a definition of success.

Each state also has exit conditions.

If verification succeeds, the machine can move toward merging. If verification fails, it can return to coding with the test output and a new hypothesis. If the same approach fails repeatedly, it can replan. It can restart with fresh context. It can also escalate.

This is loop engineering.

The important part is not that the agent retries. The important part is that the next attempt is different.

A recovery transition should add something:

  • New evidence
  • A changed hypothesis
  • A different strategy
  • Fresh context
  • A repaired environment
  • More authority

If nothing changes, the machine is not recovering. It is only repeating itself.

Loops also need limits. A good harness knows when to continue. It also knows when to stop.

Success is one final state. Blocked, unsafe, exhausted, and needs human input are valid final states too.

Design the failure transitions

In practice, we usually design the happy path well.

We know how an issue should move from definition to code, verification, and merge.

What we forget to design are the failure transitions.

  • What happens when the task is unclear?
  • What happens when the agent edits the wrong part of the system?
  • What happens when the tests pass but the result does not solve the problem?
  • What happens when the environment is broken?
  • What happens when the agent keeps attempting the same failed fix?

These should not all lead to the same “try again” transition.

Some failures need more context. Some need a new plan. Some need a clean restart. Some need a rollback. Some need a human decision.

The harness should preserve the evidence from the failure and route the work accordingly.

This is where reliable agent systems are made.

Failure transitions routed to different recovery paths instead of a single retry

Connecting loops

Small agent state machines can also be connected into larger ones. For example:

Product log analysis → Issue discovery → Engineering execution → Product launch → Product log analysis

Each part may contain its own loop. Each may have its own inputs, states, verification, recovery paths, and final conditions.

Together, they form a larger machine.

The handoffs matter. Each loop must produce something the next loop can inspect and use. Important transitions need clear checks. Otherwise, small errors travel through the pipeline and become expensive failures later.

Connected loops forming a larger pipeline, each with its own states and recovery paths

This larger system does not feel autonomous because the AI makes every decision. It feels autonomous because the software always knows what should happen next.

Hard-code conditions, not tactics

State machines do not have to make agents rigid.

Keep the states coarse. Let the agent remain flexible inside them.

Hard-code what must be true before the system moves forward. Do not hard-code every step the agent must take to make it true.

Better models can then improve the work inside each state without requiring the whole system to be redesigned.

This is the same principle we have used in software for decades: define interfaces, preserve state, check invariants, handle failure, retry carefully, escalate when necessary, stop when the terminal conditions are met.

Agents are different because their work is stochastic.

That does not make our existing software engineering intuition less useful.

It makes that intuition more important.

mindlap
AboutAtlasShowcaseCodeshotFAQPrivacyTerms

© 2026 mindlap