Every AI agent runs on a loop — perceive, reason, decide, act, verify, recover, repeat. Loop engineering is the discipline of designing that cycle on purpose instead of letting it emerge from whatever glue code happened to ship first. This page covers the discipline. Build A Harness is the open-source tool that builds it.
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 a single question runs on a loop, whether anyone designed one or not. Call a model, look at what it produced, decide what to do next, call it again. Left undesigned, that loop degrades in predictable ways: it retries forever when a tool fails, it drifts when early mistakes compound across iterations, it loses track of what it already tried, and it has no way to tell the difference between "done" and "stuck."
Loop engineering is the practice of designing that cycle deliberately — the same way you'd design a state machine, not glue code you patch after something breaks in production. It's the same underlying discipline as harness engineering, viewed through the lens of the cycle rather than the constraint structure around it.
Build A Harness is the open-source visual canvas that implements a fully engineered loop as drawable, composable nodes — world model, control state, verification, recovery, all wired into the cycle your agent actually runs on. Apache 2.0. See the tool →
Both matter. But they operate at different points in the cycle and solve different problems. In production, the returns on each are not equal.
Every node type on the canvas implements a piece of the loop — not prompt optimisation. It's the tool that makes the 28–47% reliability gain buildable without writing the cycle from scratch. See the node library →
A workflow is a straight line: input, LLM call, tool call, output, done once. It gets data where it needs to go, and it's the right tool when the number of steps is known ahead of time and the failure modes are predictable.
A loop is designed to run an unknown number of times, carrying state forward from one pass to the next. Where a workflow routes, a loop governs:
Loops are the right tool for any agent operating in an environment where the correct number of steps isn't known in advance — most agentic use cases qualify, even ones that look like simple workflows at first.
world_model · control_state · verify_gate · recovery · exp_store — these are the node types that implement what a plain workflow doesn't. Draw them on the canvas; Build A Harness generates the loop. See the tool →
You don't need every stage for every use case. But each one addresses a specific failure mode that will surface in production if left unhandled. Start with the stages your agent needs today; add the rest as the failure modes appear.
All seven stages are implemented as drawable, composable node types — tested across 379 tests. You do not write the loop's infrastructure: Build A Harness ships it. See the full node library →
Build A Harness is the open-source tool built for this discipline. It covers the full loop — from drawing the cycle on a visual canvas to compiling and running it in production — without locking you into a single framework.
Everything runs locally via Docker. No cloud account, no API key required to start — use Ollama to run a free local model if you prefer.
# 1. Generate secrets and configure environment git clone https://github.com/3IVIS/buildaharness.git && cd buildaharness ./scripts/setup-env.sh # 2. Start all nine services docker compose up
Apache 2.0. Source on GitHub →
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.
Prompt engineering optimises a single model call. Loop engineering designs what happens between calls — the state carried forward, the stopping condition, the verification each pass, and the recovery path when a pass fails. In production, loop-level design accounts for the large majority of agent reliability gains; prompt refinement beyond a reasonable baseline accounts for a small fraction.
A workflow is a straight line: input, LLM call, tool call, output, done once. A loop is designed to run an unknown number of times, carrying state forward and deciding after each pass whether to continue, escalate, retry, or stop. Workflows suit deterministic linear tasks; loops suit agents operating where the right number of steps isn't known in advance.
Yes — two names for the same discipline. Harness engineering emphasizes the constraint structure around the model; loop engineering emphasizes the iterative cycle that structure runs on. Build A Harness is the tool that implements both views at once.
The repeating cycle an autonomous agent runs through: observe the current state, reason about it, decide on an action, execute it, check the result, and repeat until a stopping condition is met. Most agent failures — infinite retries, drift, compounding hallucination, silent context loss — trace back to a loop that was never explicitly designed, not to the underlying model.
FlowSpec is the runtime-neutral JSON format at the centre of Build A Harness. You design a loop once on the visual canvas and it compiles to a FlowSpec file. That single file then runs on LangGraph, CrewAI, Mastra, or Microsoft Agent Framework without rewriting.
Clone github.com/3IVIS/buildaharness, run ./scripts/setup-env.sh && docker compose up, and open the canvas on localhost:3000. Five ready-made harnesses are included to fork and build on. No cloud account required.
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.