🎉 Giảm 20% cho đơn hàng đầu tiên!✦🚚 Miễn phí vận chuyển cho đơn trên 500.000₫✦⚡ Flash Sale — Số lượng có hạn!✦🎁 Quà tặng kèm cho đơn từ 1.000.000₫✦🎉 Giảm 20% cho đơn hàng đầu tiên!✦🚚 Miễn phí vận chuyển cho đơn trên 500.000₫✦⚡ Flash Sale — Số lượng có hạn!✦🎁 Quà tặng kèm cho đơn từ 1.000.000₫✦
Three Layers That Decide Whether Your AI Agent Works: Harness, Loop, Graph
Quay lại Blog

Three Layers That Decide Whether Your AI Agent Works: Harness, Loop, Graph

26 tháng 11, 20269 phút đọcVũ Khôi
English
#English#AI Agent#Lập trình
Vũ Khôi

Vũ Khôi

Tác giả tại Wotech Electronics Blog

Three layers around one AI agent: Harness, Loop, Graph

Three Layers That Decide Whether Your AI Agent Works: Harness, Loop, Graph

The agent breaks, you fix the prompt. It breaks again, you change the model. The third time, you add "IMPORTANT" in capital letters and pray. Whitemon opens his post on X with exactly that loop — and concludes: the bug is almost never in the prompt, and usually not in the model either. It is in the system around the model, in three layers.

Quick answer: In Whitemon's three-layer framework (summarized by Phong Ho), whether an AI agent works is decided by three layers around the model: the Harness gives the model the ability to do real work (contract, map, tools, memory, guardrails, traces), the Loop makes the agent prove the work is done with evidence instead of confidence, and the Graph splits work into nodes with clear dependencies. When an agent breaks, fix in this order: environment first, then feedback, then flow — and most work never needs a graph.

Harness, Loop, Graph are the three architectural layers around a language model in an AI agent system: the Harness is the environment — what the model can see, touch, remember, and is forbidden from; the Loop is the feedback cycle — how work is done, checked, and fixed; the Graph is the flow of work — which job runs first, which runs in parallel, and which must wait for another.

What does the prompt-fixing loop tell us?

The agent breaks, you fix the prompt. It breaks again, you change the model. The third time, you add "IMPORTANT" in capital letters and pray.

Whitemon opens his post on X with exactly that loop. In his view, the bug is almost never in the prompt, and usually not in the model either. It is in the system around the model, in three layers. Each layer fixes a different kind of failure, and fixing the wrong layer wastes a week.

He sums it up in one sentence: environment first, then feedback, then the flow of work.

Harness: giving the model hands, memory, and fences

The Harness is everything around the model that lets it do real work. The easiest way to understand it: remove the model from the system diagram, and what remains is the harness.

A good harness has 6 parts:

Part Role Failure when missing
Contract States clearly what "done" means The agent quietly solves an easier version and reports done
Map A short file pointing to where docs live Everything stuffed into the prompt, wasting tokens and confusing the model
Tools 10 narrow tools 40 overlapping tools, and the agent picks the wrong one
Memory Decisions and dead ends recorded in files Everything drifts in chat, and the agent repeats old mistakes
Guardrails Permissions the agent does not have Telling it "don't touch that" is a wish, not a wall
Traces Every run leaves a readable log Something breaks and nobody knows where

The most memorable point here is about guardrails: a sentence in the prompt is not a guardrail. Only a permission the agent genuinely does not have is a wall. If the agent can delete the production database, telling it "don't delete the database" protects nothing — you have to take that permission away.

Loop: making the agent prove the work is done

With a harness, the agent can work alone for an hour. Then it reports: "Fixed! The tests should all pass now." Notice the word "should."

The Loop is a deliberately designed cycle of doing, checking, and fixing. The most important rule: do not iterate on confidence, iterate on evidence. The agent saying it is done is not a stop condition — passing tests is.

Write the test before writing the code, and it must fail on the current code. Feedback must state four things: what was expected, what was seen, where to look, and what has already been tried. A generic "test failed" message does not help the agent fix anything.

A loop also needs an exit: a limit on attempts, a token budget, and a rule that two identical results in a row mean stop and escalate to a human. Without an exit, the agent loops forever or confidently reports done while the work is unfinished.

Graph: splitting work into the right places at the right times

A real request usually contains several jobs: fix a bug, check whether the payment and admin sections share a function, update the docs. One agent doing them one by one is slow, has only one point of view, and grades its own homework.

A Graph is made of nodes (each node one job), arrows connecting one job to another, and state kept between nodes.

In a process diagram, an arrow from job A to job B means B must wait for A to finish. For each arrow, ask: does B break if it runs before A finishes? In the post's example, checking the payment section does not need to wait for the bug fix, so it runs in parallel. Opening a merge request does need to wait for the fix, so that arrow is real.

Each agent needs its own context. Jobs whose answers never change — merging, sorting, counting — should be done by code. A node that has passed gets locked.

The author is blunt about it: most work does not need a graph. Humans are the slowest and most expensive node, so they should only stand where a mistake cannot be undone.

The closing line: the harness makes the agent capable, the loop makes it honest, the graph makes it tidy.

Which layer do you fix first?

When an agent breaks, attribute the failure to the right layer before fixing it:

Symptom Broken layer Fix
The agent cannot do the work Harness (environment) Check the contract, tools, permissions, memory
The agent is almost right but unreliable Loop (feedback) Add evidence-based checks, write tests first, set exits
Each step is fine but the process is a mess Graph (flow) Draw the nodes and arrows clearly, parallelize independent work

The investment order follows the same sequence: harness first, loop second, graph last — and last often means never. This is also where Whitemon's framework agrees with many other engineers in the field: the three layers are real, but the budgets for them are not equal at all.

Apply it now

  • Write the contract before writing the prompt: one line stating what "done" means — which tests must pass, which files must change, which docs must be updated.
  • Cut tools down to at most 10 narrow ones: remove overlapping tools; an agent that picks the right tool is faster than one that picks among many.
  • Write the test first, and it must be red on the current code: that is evidence, not the agent's word.
  • Set an exit for every loop: cap attempts and token budget; two identical results in a row mean stop and escalate to a human.
  • Draw a graph only when the steps start tangling: if one agent working sequentially is still fine, do not add a diagram — the graph is the last layer, not the first.

Frequently asked questions

1. How do Harness, Loop, and Graph differ? The Harness answers "what can the agent see and touch" (environment, tools, memory, permissions). The Loop answers "how does one attempt become correct" (do, check, fix based on evidence). The Graph answers "what is the shape of the work" (nodes, dependency arrows, parallel paths).

2. Why does fixing the prompt usually not fix a broken agent? Because the bug is almost never in the prompt. If the agent lacks tools, lacks memory, or holds overly broad permissions, no wording fixes it — the harness layer has to change.

3. When do you need a graph? When one request contains several jobs with dependencies on each other, and one agent doing them sequentially becomes slow, single-perspective, or self-grading. Most work does not need a graph — by the author's own account, the graph is the last layer, which often means never.

4. What does "don't iterate on confidence" mean? It means the loop's stop condition must be evidence — tests passing, checks met — not the agent saying "it should be done now." The agent saying it is done is not the same as it being done.

5. How does this framework relate to earlier Harness Engineering articles on Wotech? The same family of ideas: shares 37 and 96 covered Google's Harness Engineering paper (agent, model, harness in 6 layers), and share 21 covered a 5-layer model of harness, loop, graph, and factory. This article is Whitemon's compact 3-layer version, focused on diagnosing failures and the order in which to fix them.

Source: Facebook post by Phong Ho (26/11/2026), summarizing Whitemon's (@0xWhitemon) post on X about the three layers Harness, Loop, Graph. The three-layer framing is practitioner vocabulary in the agent community, not a peer-reviewed research result.