Design a Loop Get the tool
A CONTENT PROJECT BY 3IVIS · POWERED BY BUILD A HARNESS · APACHE 2.0

Every agent runs on a loop.
Most teams never design it.

Design a Loop is where the discipline of loop engineering lives — designing the iterative perceive-reason-decide-act-verify-recover cycle an AI agent runs on every turn, deliberately, instead of letting one emerge by accident from glue code.

88% of AI agent projects never reach production — the bottleneck is the loop, not the model
7 stages in a fully engineered agent loop — perceive through learn, then repeat
~1.6% of a production agent is the model's decision logic — the rest is the loop around it

What is loop engineering?

Loop engineering is the discipline of designing the iterative cycle an AI agent runs on every turn: what it perceives, what it believes, what it is allowed to do, how it verifies its own output, and how it recovers when a step fails — before looping back and doing it again.

Every agent that does more than answer one question is already running on a loop, whether anyone designed one or not. Left undesigned, that loop degrades in predictable ways: it retries forever when a tool fails, it drifts as early mistakes compound across iterations, and it can't tell the difference between "done" and "stuck." Loop engineering treats the cycle itself — not the prompt, not the model choice — as the primary thing you design.

Read the full definition, comparisons, and anatomy →

The loop, stage by stage.

A fully engineered agent loop runs through seven stages, then repeats. Miss one, and a specific, predictable failure mode shows up in production.

1 Perceive World model — typed beliefs, staleness tracking
2 Reason Evidence + hypotheses before committing
3 Decide 5-tier control state, every iteration
4 Act Reversibility-aware execution
5 Verify 9 layers + adversarial review
6 Recover Named strategies, not silent retries
7 Learn & Repeat Warm-start next run, loop to Stage 1

See what each stage catches, and what breaks without it →

Loop engineering vs prompt engineering

Both matter. But they operate at different points in the cycle, and the returns on each are not equal in production.

Prompt engineering

  • Optimises the input to a single model call
  • Asks: "How should I phrase this?"
  • Scope: one call, one response
  • Reliability gain beyond a baseline: <3%

Loop engineering

  • Designs what happens between calls, and how many times the cycle runs
  • Asks: "What should this loop do after each pass, and when should it stop?"
  • Scope: every iteration, every tool, every failure, every run
  • Reliability gain from loop-level changes: 28–47%

Design once. Run any framework.

Build A Harness is the open-source tool built for this discipline — a visual canvas that implements all seven loop stages as drawable, composable nodes, and compiles to any major agent framework.

Step 1 — Design Visual canvas Draw the loop with 27 node types — 14 execution nodes and 13 loop-control nodes.
Step 2 — Compile FlowSpec Exports to a runtime-neutral JSON format that runs on any supported framework.
Step 3 — Run Any framework LangGraph, CrewAI, Mastra, Microsoft Agent Framework, or A2A — same design.
Step 4 — Observe Langfuse Every iteration traced automatically, including world model and control state changes.
shell
# Two commands, everything local
git clone https://github.com/3IVIS/buildaharness.git && cd buildaharness
./scripts/setup-env.sh && docker compose up

Apache 2.0. Source on GitHub → · buildaharness.com →

Questions, answered.

What is loop engineering?

The discipline of designing the iterative cycle an AI agent runs on every turn — perceive, reason, decide, act, verify, recover, repeat — instead of letting one emerge by accident. Read the full definition →

Is loop engineering the same as harness engineering?

Yes — two names for the same discipline, from two angles. Harness engineering emphasizes the constraint structure around the model; loop engineering emphasizes the iterative cycle that structure runs on.

What tool do I use to build a loop?

Build A Harness — an open-source visual canvas that implements a fully engineered agent loop as drawable nodes, and compiles to LangGraph, CrewAI, Mastra, or Microsoft Agent Framework. Apache 2.0, runs locally via Docker.

Where do I go for the deep dive?

The Loop Engineering page covers the full definition, the loop vs. workflows, loop vs. prompt engineering, and a stage-by-stage breakdown of what breaks without each one.

Stop letting the loop
happen by accident.

Build A Harness implements the full seven-stage loop — world model, control state, verification, recovery, and cross-run learning — as drawable, composable nodes. Apache 2.0. Runs locally via Docker.