Glean 拾遗
Daily /2026-11-10 / Harness, Loop, Graph: Which Layer Actually Broke Your Agent

Harness, Loop, Graph: Which Layer Actually Broke Your Agent

Source x.com Glean’d 2026-11-10 06:00 Read 18 min
AI summary

The author splits agent failures into three layers: the harness (everything around the model — tools, memory, permissions, traces), the loop (a check that can genuinely fail, plus feedback and exits), and the graph (dependencies and state handoff between loops). The claim is that each layer fixes a different class of failure, and that most engineers burn weeks editing prompts or swapping models when the real defect lives elsewhere. Concrete patterns include a task contract with an explicit done_when field, an AGENTS.md file that acts as a map instead of a manual, retry loops that exit when the same evidence appears twice, and an early-start test that removes fake arrows between steps. The author concedes most tasks should collapse back to a single loop, and that drawing a twelve-node graph first is a common mistake. Suited to engineers building agent workflows. Second-hand synthesis, no original measurements.

Original · 18 min
x.com ↗
§ 1

Harness, Loop, Graph: The 3 Layers That Decide If Your AI Agent Works

Harness, Loop, Graph: The 3 Layers That Decide If Your AI Agent Works

§ 2

Your agent fails, so you rewrite the prompt. It fails again, so you switch the model. It fails a third time, so you add "IMPORTANT" in caps and hope for the best. Most people have been stuck in this cycle for a year now.

The problem is almost never the prompt, and most of the time it isn't the model either. The problem is the system around the model. In 2026 that system finally got names: harness, loop and graph.

People use these three words like they mean the same thing. They don't. Each one fixes a different kind of failure, and if you fix the wrong one you can burn a week debugging a layer that was fine all along.

This is the full breakdown: what each layer is, what it fixes, what breaks next, and how to tell which one your agent is missing. Bookmark it, you'll want the checklist later.

Agent 失败了,你改 prompt。又失败,你换模型。第三次失败,你加上大写的“IMPORTANT”,然后祈祷。大多数人已经在这个循环里困了一年。

问题几乎从来不在 prompt,多数时候也不在模型。问题出在模型周围的系统。到了 2026 年,这个系统终于有了名字:harness、loop 和 graph。

大家把这三个词当成同义词用。并不是。每一层解决的是不同种类的失败;如果修错了层,你可能花一周去调试一个本来就没问题的层。

下面把这件事讲全:每一层是什么、修什么、下一步会坏在哪,以及怎么判断你的 agent 缺的是哪一层。建议收藏,后面你会用到那份检查清单。

§ 3

§ 4

The harness gives the model hands, memory and walls. The loop gives it a check that can actually fail. The graph gives the work a shape, so the right step runs at the right time with the right inputs.

HARNESS   what the agent CAN do        environment
LOOP      how it knows it's RIGHT      evidence
GRAPH     what happens NEXT            flow

If you remember one line from this article, make it this one: environment, then feedback, then flow.

harness 给模型手、记忆和墙。loop 给它一个真的会失败的检查。graph 给工作一个形状,让正确的步骤在正确的时间、带着正确的输入运行。

HARNESS   what the agent CAN do        environment
LOOP      how it knows it's RIGHT      evidence
GRAPH     what happens NEXT            flow

如果这篇文章你只记一句话,就记这句:先环境,再反馈,最后流程。

§ 5

At the end of last year Karpathy posted the most honest description of where we all are:

Read his list again: agents, subagents, prompts, contexts, memory, modes, permissions, tools, plugins, skills, hooks, MCP. That isn't one thing. It's three layers mashed into a single sentence.

Once you split them apart, "AI agents are unreliable" stops being a mystery and turns into a normal engineering problem with normal engineering fixes.

去年年底,Karpathy 发过一段对现状最诚实的描述:

再看一遍他那个清单:agents、subagents、prompts、contexts、memory、modes、permissions、tools、plugins、skills、hooks、MCP。这不是一件东西,而是三层被揉进了一句话。

把它们拆开之后,“AI agent 不可靠”就不再神秘,而变成一个普通的工程问题,有普通的工程解法。

§ 6

The harness is everything around the model that lets it do real work. The cleanest definition I know: remove the model from your architecture diagram, and everything still on the page is the harness.

model in a repo with a terminal, tests, a browser, project memory and permissions, and it ships features. The weights didn't change. The harness did.

OpenAI ran into exactly this when they built a product with Codex and zero hand-written code. Early progress was slow, and it wasn't because the model was weak. The environment was underspecified. Their fix wasn't "try harder". They asked which capability was missing, then made it visible and enforceable for the agent.

Even Mitchell Hashimoto, the guy behind Terraform and Ghostty, says a generic agent harness beats every custom chat box he's tried:

harness 是模型周围让它能真正干活的一切。我知道的最干净的定义是:把模型从架构图里拿掉,图上剩下的一切都是 harness。

把模型放进一个带终端、测试、浏览器、项目记忆和权限的代码仓库里,它就能交付功能。权重没变,变的是 harness。

OpenAI 用 Codex 做产品、几乎不写手写代码时,撞上的正是这个问题。早期进展很慢,不是因为模型弱,而是环境定义得不够清楚。他们的修法不是“再努力一点”,而是问缺了哪种能力,然后让这种能力对 agent 可见、可强制执行。

就连 Terraform 和 Ghostty 的作者 Mitchell Hashimoto 也说,通用 agent harness 胜过他试过的每一个定制聊天框:

§ 7

§ 8
  1. Contract. Before the agent acts, turn the request into something with a finish line.
goal:        fix login redirect loop (#482)
inputs:      issue, repo, logs
output:      reviewable pull request
constraints: no schema changes, touch only auth/
done_when:   new test reproduces the bug
             same test passes after the fix
             full suite is green

The most important field here is done_when. Without it the agent will quietly solve an easier version of the task and tell you it's done.

  1. 契约。在 agent 动手之前,把请求变成一个有终点线的东西。
goal:        fix login redirect loop (#482)
inputs:      issue, repo, logs
output:      reviewable pull request
constraints: no schema changes, touch only auth/
done_when:   new test reproduces the bug
             same test passes after the fix
             full suite is green

这里最重要的字段是 done_when。没有它,agent 会悄悄去解一个更简单的版本,然后告诉你完成了。

§ 9
  1. Map. Don't dump every doc into the context window. Give the agent a short root file that tells it where things live, and let it load the details only when the task needs them.
AGENTS.md
-> architecture   docs/architecture.md
-> tests          docs/testing.md
-> security       docs/security.md
-> commands       docs/commands.md

Context isn't storage, it's an attention budget. A map saves it, a giant manual eats it before the agent writes a single line.

  1. 地图。别把所有文档都倒进上下文窗口。给 agent 一个很短的根文件,告诉它东西都在哪;只有任务需要时,再让它加载细节。
AGENTS.md
-> architecture   docs/architecture.md
-> tests          docs/testing.md
-> security       docs/security.md
-> commands       docs/commands.md

上下文不是存储,而是注意力预算。地图能省预算,一本巨型手册会在 agent 写第一行代码前就把它吃光。

§ 10
  1. Tools. Every tool you add is one more way for the model to be wrong, so ten narrow tools beat forty overlapping ones. Each tool needs a clear input, a predictable output, an explicit failure state and a permission level.
READ FILES     allowed
RUN TESTS      allowed in sandbox
WRITE FILES    allowed in workspace
NETWORK        scoped by task
DEPLOY         needs approval
DELETE DATA    needs approval
  1. 工具。你每加一个工具,模型就多一种出错方式,所以十个窄工具胜过四十个互相重叠的工具。每个工具都需要清楚的输入、可预测的输出、明确的失败状态和权限等级。
READ FILES     allowed
RUN TESTS      allowed in sandbox
WRITE FILES    allowed in workspace
NETWORK        scoped by task
DEPLOY         needs approval
DELETE DATA    needs approval
§ 11
  1. Memory. The context window is RAM and the harness is the disk. Decisions, dead ends and open risks go into files and git commits, not into the chat.
PROGRESS.md
goal    fix #482 login redirect loop
tried   reorder auth middleware -> still red
known   only happens with expired session cookie
next    inspect auth/refresh.py
never   touch migrations/

This is how an agent survives a crash, a context reset or a handoff. The next session inherits the actual state of the work instead of a blurry summary of the conversation.

  1. 记忆。上下文窗口是内存,harness 是硬盘。决策、死路和未解决的风险要写进文件和 git commit,不是留在聊天里。
PROGRESS.md
goal    fix #482 login redirect loop
tried   reorder auth middleware -> still red
known   only happens with expired session cookie
next    inspect auth/refresh.py
never   touch migrations/

这样 agent 才能扛住崩溃、上下文重置或交接。下一个会话继承的是工作的真实状态,而不是一段模糊的对话摘要。

§ 12
  1. Walls. "Please don't touch migrations" is a wish. A permission the agent doesn't have is a wall. The model can suggest an action, but a policy outside the model decides whether it runs. Never let the same system invent the plan, approve the risk and execute the side effect.

  2. Traces. Every run should leave a trail you can actually read: what context was loaded, which tools were called, what changed, which tests ran, how many retries, how much it cost. Without traces a failure is a mystery. With traces it's input for the next fix.

  1. 墙。“请不要碰 migrations”只是愿望。agent 没有的权限才是墙。模型可以建议一个动作,但由模型之外的策略决定它能不能执行。永远不要让同一个系统既制定计划、又批准风险、还执行副作用。

  2. trace。每次运行都应该留下你能读懂的轨迹:加载了什么上下文、调用了哪些工具、改了什么、跑了哪些测试、重试了几次、花了多少钱。没有 trace,失败就是谜;有了 trace,失败就是下一次修复的输入。

§ 13

Most teams keep their important rules in prose. The agent reads them, follows them for a while, and then one day it ignores one. The fix is to write every important rule twice: once as guidance the agent can understand, and once as a check it can't get around.

GUIDE  (AGENTS.md, the agent reads it)
UI code may not query the database directly

CHECK  (CI, the agent can't argue with it)
lint fails if src/ui/** imports src/db/**

The guide explains the reason. The check holds even on the day the model ignores the guide. Over time this turns past mistakes into infrastructure, so the next agent doesn't have to remember the incident because the harness remembers it.

大多数团队把重要规则写成散文。agent 读了,遵守一阵子,然后某天忽然无视其中一条。修法是:每条重要规则都写两遍,一遍是 agent 能理解的指南,一遍是它绕不过去的检查。

GUIDE  (AGENTS.md, the agent reads it)
UI code may not query the database directly

CHECK  (CI, the agent can't argue with it)
lint fails if src/ui/** imports src/db/**

指南解释原因,检查则在模型无视指南的那天依然有效。时间一长,过去的错误就变成了基础设施;下一个 agent 不必记住那次事故,因为 harness 记得。

§ 14

Anthropic now basically sells this whole layer as a product. The model reasons, the sandbox acts, and the session log survives if either one dies:

Anthropic 现在基本把这一整层当产品在卖。模型负责推理,沙箱负责执行,会话日志在任意一方挂掉后还能留下来:

§ 15

With a decent harness your agent can work alone for an hour. Then it finishes with "Fixed! All tests should pass now." Notice the word "should". The harness made the agent capable, but nothing in the system makes it correct yet.

有了像样的 harness,你的 agent 可以独自工作一小时。然后它结束时说:“修好了!现在所有测试应该都能过。”注意“应该”这个词。harness 让 agent 有能力,但系统里还没有任何东西让它正确。

§ 16

Every agent already has a tiny loop inside it: call the model, run a tool, feed the result back, repeat. Loop engineering starts when you design that cycle on purpose. Not "ask again", not "retry", but a real work-and-feedback system with a goal, evidence and a way to stop.

It went mainstream fast. Claude Code even shipped it as a command:

每个 agent 内部本来就有个小循环:调用模型、运行工具、把结果喂回去、重复。循环工程从你有意设计这个周期开始。不是“再问一次”,不是“重试”,而是一个真正的工作与反馈系统,有目标、有证据、有停止方式。

它很快就主流化了。Claude Code 甚至把它做成了一个命令:

§ 17

§ 18
TRIGGER    what starts a cycle (failed test, new ticket, schedule)
GOAL       the exact condition we want, not "keep improving"
STATE      what the next cycle needs to know
ACTION     what the agent is allowed to do
EVIDENCE   how we know it worked
FEEDBACK   what exactly failed
STOP       when it ends, no matter what

The most important rule of loop engineering fits in one line: don't loop on confidence, loop on evidence. "The agent says it's done" is not a stop condition. Tests passing is.

TRIGGER    what starts a cycle (failed test, new ticket, schedule)
GOAL       the exact condition we want, not "keep improving"
STATE      what the next cycle needs to know
ACTION     what the agent is allowed to do
EVIDENCE   how we know it worked
FEEDBACK   what exactly failed
STOP       when it ends, no matter what

循环工程最重要的规则一行就能说完:不要按信心循环,要按证据循环。“agent 说完成了”不是停止条件,测试通过才是。

§ 19

§ 20
STRONGEST    deterministic   tests exit 0, schema validates, build compiles
             observable      the trace shows it really ran the test
             independent     a reviewer in a separate context
WEAKEST      self-report     "looks good", "I'm confident", "should pass"

A check is only as strong as the weakest thing it accepts as proof. If your loop accepts "the model says it's done", it's a self-report loop no matter how many steps it has.

STRONGEST    deterministic   tests exit 0, schema validates, build compiles
             observable      the trace shows it really ran the test
             independent     a reviewer in a separate context
WEAKEST      self-report     "looks good", "I'm confident", "should pass"

一个检查的强度,取决于它能接受的最弱证据。如果你的循环接受“模型说完成了”,那不管它有多少步,它都是自报式循环。

§ 21

Before the agent touches a single file, write down what green means, and include a test that fails on the current code. A test that already passes before the fix proves nothing. There's a bonus here too: if you can't write the check, you don't actually understand the task yet. Writing the check is writing the spec.

在 agent 碰任何文件之前,先写下什么叫绿,并加入一个会在当前代码上失败的测试。修复前就已经通过的测试证明不了任何东西。这里还有个额外好处:如果你写不出检查,说明你还没真正理解任务。写检查就是写规格。

§ 22

"Red" is a verdict, and it tells the agent almost nothing. Real feedback says what was expected, what actually happened, where to look, and what has already been tried:

FAILED      test_expired_session_redirect
EXPECTED    302 -> /login
SAW         302 -> /dashboard  (auth/refresh.py:61)
FENCE       auth/refresh.py only
DEAD ENDS   middleware reorder

EXPECTED vs SAW turns a red light into a direction. DEAD ENDS stops attempt three from quietly turning back into attempt one.

“红”是判决,它几乎不告诉 agent 任何东西。真正的反馈要说清楚:期望是什么、实际发生了什么、该去哪看、已经试过什么:

FAILED      test_expired_session_redirect
EXPECTED    302 -> /login
SAW         302 -> /dashboard  (auth/refresh.py:61)
FENCE       auth/refresh.py only
DEAD ENDS   middleware reorder

EXPECTED 和 SAW 把红灯变成方向。DEAD ENDS 则阻止第三次尝试悄悄变回第一次。

§ 23

A loop without exits isn't persistence, it's a cost leak.

for attempt in range(3):
    artifact = build(state)
    evidence = verify(artifact)          # tests, not vibes

    if evidence.passed:
        return artifact
    if evidence.saw in state.dead_ends:  # same result twice
        break
    state.dead_ends.append(evidence.saw)
    state.repair = evidence.gap

return escalate_to_human(state)

The middle rule matters most. When the agent gets the exact same result twice, it has stopped learning from the loop and more attempts won't help. The missing piece is something it can't see, or the task was framed wrong. A loop can fix the work, but it can't fix the question.

Look at tip number five from the guy who built Claude Code. That's loop engineering in one sentence:

没有退出的循环不是坚持,是成本泄漏。

for attempt in range(3):
    artifact = build(state)
    evidence = verify(artifact)          # tests, not vibes

    if evidence.passed:
        return artifact
    if evidence.saw in state.dead_ends:  # same result twice
        break
    state.dead_ends.append(evidence.saw)
    state.repair = evidence.gap

return escalate_to_human(state)

中间那条规则最重要。当 agent 连续两次得到完全相同的结果,它已经不再从循环里学到东西,再试更多次也没用。缺的那块可能是它看不见的东西,也可能是任务本身定义错了。循环能修工作,但修不了问题本身。

看看 Claude Code 作者提的第五条建议。那就是一句话的循环工程:

§ 24

What Breaks Next

Now every individual step is great. But the real ticket was never one step. It was: fix the bug, check whether billing and admin use the same helper, and update the docs.

One agent does all of it in a line, inside one context. The second audit reads the first one's notes and just repeats them. The whole thing is slow, serial and holds one opinion, and on top of that the same agent grades its own work. No amount of loop tuning fixes this, because the problem isn't inside any step. It's between them.

接下来会坏在哪

现在每个单独步骤都很棒。但真实工单从来不是一步:修 bug、检查 billing 和 admin 是否用同一个 helper、更新文档。

一个 agent 在一个上下文里一口气全做了。第二次审计读到第一次的笔记,然后只是重复它。整个过程又慢又串行,而且只有一种观点;更糟的是,同一个 agent 还给自己打分。再怎么调循环也修不好,因为问题不在任何一步里面,而在步骤之间。

§ 25

In July one short question from Peter Steinberger got 3.1M views:

The timeline answered within hours:

What It Is

七月,Peter Steinberger 发了一个短问题,拿到 310 万浏览:

时间线几小时内就给出了回答:

它是什么

§ 26

A graph is three things. Nodes are bounded jobs with one input and one output. Edges are real dependencies, where one node's output feeds another node's input. State is whatever survives between nodes.

NODE    one bounded job, one input in, one output out
EDGE    a real dependency, this output feeds that input
STATE   what survives between nodes

Here's the part that makes it click: a loop is just a graph with one node and an edge back to itself. The graph doesn't replace your loops. It's what you need once several loops have to hand work off to each other.

图就是三样东西。节点是有边界的任务,一进一出。边是真实依赖:一个节点的输出喂给另一个节点的输入。状态是节点之间活下来的东西。

NODE    one bounded job, one input in, one output out
EDGE    a real dependency, this output feeds that input
STATE   what survives between nodes

真正让它开窍的是这句:循环不过是一个节点、一条指回自己的边的图。图不是替代你的循环,而是当多个循环必须互相交接工作时,你才需要的东西。

§ 27

§ 28

Most arrows in a workflow diagram aren't real dependencies. They're habits, just the order someone happened to think of the steps. So for every arrow, ask what would break if B started before A finished. If the answer is "nothing", delete the arrow and run them in parallel.

Can the billing audit start before the fix lands? Yes, so it runs in parallel. Can the PR open before the fix lands? No, so that arrow is real.

流程图里大多数箭头都不是真依赖。它们只是习惯,是某人碰巧想到步骤的顺序。所以对每个箭头都问一句:如果 B 在 A 完成前就开始,会坏什么?如果答案是“什么都不会坏”,删掉箭头,让它们并行。

billing 审计能在修复落地前开始吗?能,所以并行跑。PR 能在修复落地前开吗?不能,所以这条箭头是真的。

§ 29

Split where things fail separately. If two steps can break for different reasons, they're two nodes. If they always break together, they're one.

Give every worker its own context. Four agents sharing one context aren't a team, they're one agent wearing four hats. The first opinion written down becomes everyone's opinion.

按故障边界拆。两个步骤如果能因为不同原因坏掉,它们就是两个节点;如果总是一起坏,它们就是一个。

给每个 worker 独立上下文。四个 agent 共享一个上下文,不是团队,是一个 agent 戴四顶帽子。第一个写下来的观点,会变成所有人的观点。

§ 30

If the answer should never change, it's code. Merging, sorting, deduping and counting are plain functions. Use a model only where a different answer could also be right.

Freeze what passed. Once a node gets through its gate, its output is read-only. When something fails, rerun only that node with its feedback. Rerunning good work is just a free chance to break it.

This is the real reason graphs exist, and Rohit put it well:

如果答案不该变,就交给代码。合并、排序、去重、计数都是普通函数。只有在不同答案都可能正确的地方,才用模型。

冻结已经通过的东西。一个节点过了闸门,它的输出就是只读的。出问题时,只带反馈重跑那个节点。重跑已经好的工作,只是免费给自己一次弄坏它的机会。

这才是图存在的真正原因,Rohit 说得好:

§ 31

Most tasks don't need one. If you can collapse your five nodes back into a single loop and lose nothing, do it. And to be fair to the skeptics, LangGraph and Google ADK were doing nodes, edges and shared state long before the hashtag. The word is new, but the move from one loop to coordinated nodes is real. Just don't reach for it until the work forces you to.

大多数任务不需要图。如果你能把五个节点压回一个循环而不损失任何东西,那就压回去。也为怀疑者说句公道话:LangGraph 和 Google ADK 在 hashtag 出现之前很久就在做节点、边和共享状态了。词是新的,但从一个循环走向协同节点这件事是真的。只是别在工作逼你之前伸手去拿它。

§ 32

At level zero you are the whole system. Your hands run the code, your eyes check the result, and your head decides what happens next. The model is the only part that isn't doing the hard work.

The goal isn't an agent that never needs you. You're the slowest and most expensive node in the graph, so put yourself only where a mistake can't be taken back. Gate on the price of undo, not on the model's confidence:

在第零层,你就是整个系统。你的手跑代码,你的眼睛检查结果,你的脑袋决定下一步。模型是唯一没在做苦活的部分。

目标不是做一个永远不需要你的 agent。你是图里最慢、最贵的节点,所以只把自己放在错误无法收回的地方。按撤销的代价设闸门,而不是按模型的信心:

§ 33
ONE-CLICK UNDO   docs, tests, one function      ships on green
CLEANUP UNDO     shared helpers, auth, schemas  green + trace + second opinion
NO UNDO          migrations, deletes, emails, $ a human signs

The last tier has no score attached. Not 0.95, not 0.99. There's no number for the model to beat, so there's nothing to argue with.

ONE-CLICK UNDO   docs, tests, one function      ships on green
CLEANUP UNDO     shared helpers, auth, schemas  green + trace + second opinion
NO UNDO          migrations, deletes, emails, $ a human signs

最后一档不附分数。不是 0.95,不是 0.99。没有数字让模型去刷,也就没什么好争的。

§ 34

§ 35

Before you change anything, find your first symptom from the top of this list. That's your next fix, not the one after it.

SYMPTOM                                         FIX THE
you copy-paste between chat and terminal        harness (tools)
it retries things it already tried              harness (memory)
"done" means nothing until you check            loop (the check)
retries burn budget on the same error           loop (feedback + exits)
every step is right, the whole thing is slow    graph (shape)
one failure means everything reruns             graph (gates)
the same mistake comes back every week          all layers (learning)

动手改任何东西之前,先从这张表顶部找到你的第一个症状。那才是你下一步要修的东西,不是再下一步。

SYMPTOM                                         FIX THE
you copy-paste between chat and terminal        harness (tools)
it retries things it already tried              harness (memory)
"done" means nothing until you check            loop (the check)
retries burn budget on the same error           loop (feedback + exits)
every step is right, the whole thing is slow    graph (shape)
one failure means everything reruns             graph (gates)
the same mistake comes back every week          all layers (learning)
§ 36

Most people fix the output. Good teams fix the class of failure, and the trick is filing each lesson in the layer that owns it.

FAILURE                               LESSON BECOMES               LAYER
couldn't see production logs          read-only log tool           harness
retried last week's dead approach     line in the "never" list     harness
touched a file it shouldn't           permission it no longer has  harness
"fixed" with no reproducing test      required check in CI         loop
same error 6 times in a row           same-result-twice exit       loop
two audits overlapped                 split rule in scope node     graph
typo and auth change got same review  undo-price gate              graph

Notice there's no "prompt" row. "Be careful not to duplicate work" in a prompt is a hope, while a split rule in the scheduler is structure. Next quarter's model will read your prompt differently, but a test reads the same way forever.

大多数人修输出。好团队修这一类失败,诀窍是把每条教训归档到拥有它的层。

FAILURE                               LESSON BECOMES               LAYER
couldn't see production logs          read-only log tool           harness
retried last week's dead approach     line in the "never" list     harness
touched a file it shouldn't           permission it no longer has  harness
"fixed" with no reproducing test      required check in CI         loop
same error 6 times in a row           same-result-twice exit       loop
two audits overlapped                 split rule in scope node     graph
typo and auth change got same review  undo-price gate              graph

注意没有“prompt”这一行。prompt 里写“注意不要重复工作”只是愿望,调度器里的拆分规则才是结构。下个季度的模型会用不同方式读你的 prompt,但测试永远用同一种方式读。

§ 37
  1. Building the graph too early. People draw a twelve-node diagram before they've watched the agent do the job once. Start with a harness and one loop, collect traces, and formalize only what actually deserves it.

  2. The same model writes and grades. Self-review shares the same blind spots as the original work. Use tests first, a reviewer in a separate context second, and a human for anything you can't undo.

  1. 太早搭图。人们还没看 agent 做过一次这件事,就先画十二个节点的图。先从 harness 和一个 loop 开始,收集 trace,只把真正值得形式化的东西形式化。

  2. 同一个模型既写又评。自我评审和原始工作共享同样的盲区。先用测试,其次用独立上下文里的评审者,最后对任何无法撤销的事用人。

§ 38
  1. "Keep trying" as a loop. That isn't a loop, it's an open tab on your credit card. Every loop needs a goal, real evidence, a retry cap and an exit.

  2. The harness as a junk drawer. More tools don't make a better agent, they make more wrong choices. A good harness isn't crowded, it's precise.

  3. Blaming the model. No model can compensate for broken APIs, stale state, vague tool schemas or missing exits. Fix the layer that owns the failure.

  1. 把“继续试”当循环。那不是循环,那是你信用卡上一直开着的标签页。每个循环都需要目标、真实证据、重试上限和退出。

  2. 把 harness 当杂物抽屉。更多工具不会让 agent 更好,只会让它做更多错误选择。好的 harness 不拥挤,它精确。

  3. 怪模型。再强的模型也补不了坏掉的 API、过期的状态、含糊的工具 schema 或缺失的退出。修拥有这次失败的那一层。

§ 39

§ 40

Harness

  • Success is defined before the run starts

  • The root guide is a map, not a manual

  • Every tool has a clear contract and failure state

  • Decisions live in files, not in the chat

  • The agent runs in a sandbox or worktree

  • Every tool call is traced Loop

  • Green is written before the code

  • The check fails at least once on purpose

  • Feedback says expected vs saw

  • There's a retry cap and a token budget

  • Same result twice means escalate Graph

  • You tried to keep it a single loop first

  • Every arrow passed the early-start test

  • Each worker has its own context

  • Passed nodes are frozen

  • Gates are priced by undo, not confidence

Harness

  • 运行开始前就定义了成功

  • 根指南是地图,不是手册

  • 每个工具都有清楚的契约和失败状态

  • 决策落在文件里,不在聊天里

  • agent 在沙箱或 worktree 里运行

  • 每次工具调用都有 trace Loop

  • 先写绿,再写代码

  • 检查至少故意失败过一次

  • 反馈说明 expected 与 saw

  • 有重试上限和 token 预算

  • 同一结果出现两次就升级 Graph

  • 你先试过保持单循环

  • 每条箭头都通过了早启动测试

  • 每个 worker 有自己的上下文

  • 通过的节点被冻结

  • 闸门按撤销成本定价,不按信心

§ 41

If several of these are a no, a smarter model won't save you. It'll just make the failure faster and more expensive.

如果其中好几项都是否,更聪明的模型救不了你。它只会让失败来得更快、更贵。

§ 42

Prompt engineering tells the model what to do. Context engineering decides what it sees. Harness engineering builds the world it acts in. Loop engineering makes it prove its work. Graph engineering decides who does what next.

PROMPT    -> instruction
CONTEXT   -> working view
HARNESS   -> environment
LOOP      -> evidence
GRAPH     -> coordination

Prompt engineering 告诉模型做什么。Context engineering 决定它看到什么。Harness engineering 搭出它行动的世界。Loop engineering 让它证明自己的工作。Graph engineering 决定下一步谁来做。

PROMPT    -> instruction
CONTEXT   -> working view
HARNESS   -> environment
LOOP      -> evidence
GRAPH     -> coordination
§ 43

Models will keep changing every quarter. Your contracts, tools, tests, state files and gates stay, and they get better with every failure you file in the right place. That's where the real advantage lives now.

The harness makes the agent capable. The loop makes it honest. The graph makes it organized.

Next time your agent says "done", ask which layer said so.

模型每个季度都会换。你的契约、工具、测试、状态文件和闸门会留下,而且你每把一次失败归到正确的层,它们就更好一点。真正的优势现在在这里。

harness 让 agent 有能力。loop 让它诚实。graph 让它有条理。

下次你的 agent 说“完成了”,问一句:是哪一层说的。

§ 44

Bookmark this so you have the checklist the next time you build an agent.

Follow @0xWhitemon for more breakdowns like this.

And send it to the one friend who still fixes every agent bug with a longer prompt.

收藏这篇,下次搭 agent 时你就有那份检查清单。

关注 @0xWhitemon,看更多这样的拆解。

也把它发给那个还在用更长 prompt 修所有 agent bug 的朋友。

Open source ↗