Series: Harness Engineering (3/3)
Table of Contents
The first two posts covered the concept of Harness Engineering and the five engineering practices from OpenAI’s million-line Codex project. This post shifts the lens to industry-wide comparison to answer a more practical question:
If I’m not OpenAI and I don’t have Codex, how does this methodology land on my own project?
Four parts: first, the recurring failure modes of Agents (what enemy Harness is fighting); second, the context sweet spot (a quantified rule of thumb); third, the four-pillar framework the industry has converged on (what everyone is doing); fourth, the three-phase rollout roadmap (where to start). We close with six points of established consensus and three problems the industry still has no answer to.
Four Recurring Agent Failure Modes
Before talking frameworks, know the enemy. Anthropic distilled four recurring failure modes from their extensive practice with long-running Agents. These four modes are model-agnostic, harness-agnostic, task-agnostic — as long as you let an Agent run autonomously, they show up. Understanding them is the starting point of Harness design.
One: One-shotting (trying to finish in one go)
Agents have a strong tendency to try to complete the whole thing in a single turn. Halfway through implementation, the context window runs out; when the next session starts, it finds a half-finished, undocumented codebase and has to spend enormous token budget guessing “what happened before” and trying to recover working state. This is the Agent version of “blacked out last night, don’t know where I am this morning.”
Two: Declaring victory too early
Late in the project, when part of the functionality is done, the Agent looks around, sees existing progress, and declares the task complete — even when substantial functionality is still missing. It’s biased toward picking whatever state “feels roughly done” as the endpoint, instead of verifying item-by-item against the original spec.
Three: Marking features done too early
The Agent finishes writing code and marks it “done” — but hasn’t done end-to-end testing. Unit tests pass, curl returns a response on the API, TypeScript compiles — these count as “done” to the Agent, but there’s a large gap between that and “a user can actually operate this normally.”
Four: Environment cold-start tax
Every new session, the Agent has to spend a large token budget figuring out “how does this project run,” “which port is the dev server on,” “how does the DB connect” — instead of putting time toward actual development. Every session pays this tax.
These four problems share a common root: Agents lack structured working memory and clear completion criteria. One of the core tasks of Harness design is to solve these problems at the system level, not patch them each time with a better prompt. You’ll notice the four pillars below have components that map directly to these four failure modes — not a coincidence.
The Context Sweet Spot: The 40% Rule
Before entering the framework, another concept must be established first: more context isn’t better.
This sounds counterintuitive — intuitively, more information should help the Agent — but industry observations consistently point the other way. With a 168K token context window as an example, performance starts declining around 40% utilization:
Below 40% (Smart Zone): focused, accurate reasoning.
The Agent has relevant, distilled information.
Above 40% (Dumb Zone): hallucinations, loops, malformed tool calls,
low-quality code. More tokens actually hurt.
The phenomenon has quantitative support. Experiments have shown that merely changing the tool interface format of the Harness can drastically improve the same model’s coding benchmark score — some models jump from single-digit scores to over 60%, with weights untouched. LangChain has reported similar effects: Harness improvements alone moved the same model from 30th to 5th place on Terminal Bench 2.0.
Together, these data points make one thing clear: before you agonize over whether to use Claude or GPT, examine your Harness design. Stuffing the Agent with MCP tools, verbose docs, and accumulated dialogue history doesn’t make it smarter — it pushes it into the Dumb Zone.
The 40% rule isn’t a hard number (it varies by model and task), but the direction is stable: context is a scarce resource; spend it carefully. This mindset runs through all the pillars that follow.
Four Pillars: The Industry-Converged Framework
Combining practice from OpenAI, Anthropic, Stripe, the Anthropic C compiler project, and Hashimoto’s Ghostty work, four patterns recur and have converged. They form the four pillars of Harness Engineering.
graph TD
A["Four Pillars"] --> B["Context Architecture"]
A --> C["Agent Specialization"]
A --> D["Persistent Memory"]
A --> E["Structured Execution"]
B -.counters.-> B1["Dumb Zone / cold-start tax"]
C -.counters.-> C1["Generic-agent context pollution"]
D -.counters.-> D1["One-shotting / declaring victory"]
E -.counters.-> E1["Marking done too early / drift"]
Each pillar corresponds to a specific failure mode it counters. This isn’t a theoretical taxonomy — it’s an executable framework filtered from hundreds of industry potholes.
Pillar 1: Context Architecture
Core principle: the Agent should get exactly the context needed for the current task — no more, no less.
This is the direct landing of the 40% rule at framework level. Every team independently discovered: cramming all instructions into a single file doesn’t scale. Part 2 mentioned OpenAI’s “map mode” AGENTS.md; other teams evolved similar layered mechanisms. The three-tier structure that emerged:
| Tier | Load timing | Example content | Footprint |
|---|---|---|---|
| Tier 1: session-resident | Auto-loaded per session | AGENTS.md / CLAUDE.md, project structure overview | Minimal (few hundred tokens) |
| Tier 2: on-demand | Loaded when specific sub-agents or skills are invoked | Specialized Agent contexts, domain knowledge | Medium |
| Tier 3: persistent knowledge base | Queried only when Agent proactively pulls it | Research docs, specs, historical sessions | On-demand |
There’s a key insight behind this layering: not all knowledge is worth loading at session opening. Some knowledge might only get used 5% of the time (e.g., the error-code manual) — putting it in Tier 3 and querying on demand is far more efficient than parking it in Tier 1.
In practice, Tier 1 is your AGENTS.md (paired with the map mode from the previous post); Tier 2 is your role-specific sub-agent configs; Tier 3 is your docs/reference/ directory or vector search database.
Pillar 2: Agent Specialization
Core principle: Agents focused on specific domains with restricted tools outperform generalist Agents with full permissions.
This principle sounds counterintuitive on first read — isn’t a more specialized Agent more limited? Why would it be stronger? The answer has two layers:
- Cleaner context: specialized Agents carry less irrelevant information and permanently run inside the Smart Zone.
- Smaller tool permissions, smaller error blast radius: a read-only Agent doesn’t accidentally delete files; an Agent scoped to specific directories doesn’t pollute other modules.
This translates in practice to clear role division:
| Agent Role | Scope | Tool Permissions |
|---|---|---|
| Research Agent | Explore codebase, analyze implementation details | Read-only (Read, Grep, Glob) |
| Planning Agent | Decompose requirements into structured tasks | Read-only, no write |
| Executor Agent | Implement individual concrete tasks | Scoped read/write |
| Reviewer Agent | Audit completed work, flag issues | Read-only + flag |
| Debugger Agent | Fix issues surfaced by review | Scoped fix permissions |
| Cleanup Agent | Fight entropy, clean low-quality code | Read/write (with rollback) |
Anthropic’s C compiler project split Agents into four roles: compiler core, dedup, performance optimization, docs. The dedup Agent exists precisely because LLMs have the “reinvent the wheel” tendency mentioned in the previous post — a dedicated Agent is needed to handle it. This is a purely mechanical context-management decision.
Pillar 3: Persistent Memory
Core principle: progress is persisted on the filesystem, not in the context window.
Agents have no true memory. Every new session starts from scratch. So rather than hoping “the Agent remembers what it did before,” force the Agent to write progress to files it can read back next time.
Anthropic’s approach is a worth-copying two-stage architecture:
Initialization Agent (runs once): uses a dedicated prompt to build the initial environment, producing three artifacts — init.sh startup script, claude-progress.txt progress log, initial git commit + structured feature list (in JSON).
Executor Agent (every session): asked to make incremental progress and leave structured updates. Each session’s startup flow is fixed into a mechanical SOP:
- Run
pwdto confirm working directory - Read
git logand progress file to understand recent work - Read the feature list (JSON), pick the highest-priority unfinished feature
- Run
init.shto bring up the dev server and run baseline end-to-end tests - After confirming basic functionality works, start new feature development
This SOP simultaneously solves three failure modes mentioned earlier: cold-start tax (init.sh handles the environment), declaring victory (there’s a clear JSON list to check against), and one-shotting (each session picks only one feature, hands off when done).
One practical detail worth remembering: tracking feature status with JSON works better than Markdown — because the Agent is less likely to inappropriately modify or overwrite structured data. Markdown is too free; the Agent might accidentally flip [ ] to [x] without actually doing it. JSON has schema-feel; the Agent hesitates before mutating. This “using data-structure rigidity to replace prompt softness” is a classic Harness Engineering technique.
Pillar 4: Structured Execution
Core principle: separate thinking from execution. Research and planning happen in controlled phases; execution runs on a validated plan.
Every team independently discovered the same pattern: understand → plan → execute → verify must be deliberately kept as four separate phases, not blended together.
Cloudflare’s Boris Tane stated the principle most directly:
Never let the Agent write code before you’ve reviewed and approved a written plan. This separation of planning and execution has been the single most important thing I’ve done.
The cost logic behind it is clear: reviewing a plan is much faster than reviewing code. When the spec is correct, implementation naturally follows reliably; when the spec is wrong, you can stop it before 500 lines of code get generated, instead of discovering the direction was wrong after the fact.
There’s a corollary: the human should engage heavily during planning, then fully step back during execution. This is also why mainstream Agent tools like Cline, Claude Code, and Aider all ship with a “Plan Mode / Act Mode” toggle — it’s not a gimmick, it’s the engineering embodiment of this principle.
Three-Phase Rollout Roadmap
With the framework understood, the most practical question is: where to start?
Harness Engineering isn’t a one-shot deal — it’s incremental. Many teams fail by trying to build all infrastructure at once. Here’s a pragmatic three-phase path:
Phase 1: Information Layer (1-2 days)
┌─────────────────────────────────┐
│ AGENTS.md map mode │
│ Structured docs/ directory │
│ Coding conventions written down │
└─────────────────────────────────┘
Payoff: Agent output consistency ↑
↓
Phase 2: Constraint Layer (3-5 days)
┌─────────────────────────────────┐
│ Layered architecture + linters │
│ CI constraint checks │
│ Error messages with fix hints │
└─────────────────────────────────┘
Payoff: Code quality controllable (inflection point)
↓
Phase 3: Automation Layer (1-2 weeks)
┌─────────────────────────────────┐
│ Agent self-verification loop │
│ Background cleanup Agent │
│ Observability wiring │
└─────────────────────────────────┘
Payoff: Human review load drops sharply
Phase 1: Information Layer (start this afternoon)
Do exactly one thing: move project knowledge scattered across Slack, Google Docs, and people’s heads into the git repo. Write a 50–100 line AGENTS.md in map mode, then distribute details across structured directories like docs/architecture/, docs/conventions/, docs/plans/.
Payoff is direct: the Agent starts producing consistent, on-team-style code, because it can finally “see” your conventions.
Critical warning: don’t let AGENTS.md exceed 100 lines. Beyond that, you’re challenging the context ceiling and violating the 40% rule. You’ll be tempted to write every rule in there — resist.
Phase 2: Constraint Layer (the real inflection point)
Phase 1 lets the Agent “know” the rules; Phase 2 makes it so the Agent “can’t help but follow” the rules. The core action is translating verbal conventions into linter rules and CI checks.
There’s a useful practical heuristic: if a rule has been raised in Code Review more than 3 times, it should be a linter rule. Start with the most painful one, handle three to five per week, and you’ll soon notice Code Review content shifting from “style issues” to “design issues.”
Every linter rule’s error message should follow the three-part structure from the previous post:
❌ [what's wrong]
✅ FIX: [specifically how to fix it — code snippet if possible]
📖 See: [which doc has the details]
This is the highest-leverage practice of Phase 2. Every linter rule you write is essentially a prompt — when designing error messages, treat the Agent as your user, not as a coworker.
Phase 3: Automation Layer (nice-to-have for long-term projects)
Phase 3 is the quantitative-to-qualitative shift. When the Agent can start the app itself, screenshot to verify, query logs to debug, the human engineer truly transitions from “reviewer” to “safety net.”
Three key actions at this stage:
- Git Worktree isolated verification: let the Agent run PRs in isolated environments without stepping on each other
- Background cleanup Agent: run doc-gardening, dead-code sweeps, duplicate-implementation detection on a schedule
- Observability wiring: let the Agent query logs and metrics with LogQL / PromQL, or at least read local log files
Phase 3’s payback period is longer, suitable for projects that have been stable for months and are confirmed for long-term maintenance. Just-launched new projects don’t need to rush into this.
Six Points of Industry Consensus
Cross-referencing OpenAI, Anthropic, Stripe, Martin Fowler, Mitchell Hashimoto, and other independent sources, these six points have formed strong consensus — multiple independent teams, independent practices, independently arriving at the same conclusion:
Consensus 1: The bottleneck is infrastructure, not model intelligence.
Multiple independent experiments confirm that Harness design changes alone can drastically improve the same model’s performance. Before switching models, examine your Harness — the ROI is typically an order of magnitude higher.
Consensus 2: Docs must be a live feedback loop, not a static artifact.
Every line of AGENTS.md should correspond to a past Agent failure case. Update the doc every time an Agent errs, so the same error never happens twice. Docs aren’t monuments written for humans; they’re operating manuals for Agents.
Consensus 3: Thinking and execution must be separated.
Never let the Agent write code before you’ve reviewed and approved a written plan. This is the iron law every team independently discovered.
Consensus 4: More context isn’t better.
Past 40%, you enter the Dumb Zone. Layered progressive disclosure beats cramming everything into one file.
Consensus 5: Constraints must be enforced mechanically, not only documented.
OpenAI’s phrasing is direct: “if it cannot be enforced mechanically, agents will deviate.” Linters, CI, and structure tests are standard, not optional.
Consensus 6: The engineer’s role is shifting from ‘writing code’ to ‘designing environments + managing work’.
Code quality has moved from personal virtue to system property. Discipline no longer lives in the code — it lives in the supporting structures, tools, abstractions, and feedback loops.
These six can serve as a checklist for Harness Engineering — when a decision you’re making violates one of them, that’s usually a signal something is off and you should stop to review.
Three Still-Open Problems
Beyond consensus, the industry also recognizes three hard problems for which no team has a satisfying answer yet. Understanding these limits helps set realistic expectations when introducing Harness.
Open Problem 1: Retrofitting brownfield projects
Every publicly reported success case — OpenAI, Carlini’s C compiler, Anthropic, Stripe, Hashimoto — is a greenfield project, or a Harness built from scratch.
For a ten-year-old codebase with no architectural constraints, inconsistent tests, and stale docs, how do you incrementally introduce a Harness? Zero success cases, zero methodology so far. Martin Fowler analogized this to “enabling strict linting on a codebase that never had static analysis — you get drowned in warnings and can’t change anything.”
This gap is critical because most teams face brownfield. Possible directions include starting from a single module, doing an “AI code archaeology” pass first before writing rules, or temporarily loosening thresholds and tightening incrementally — but all of these are still experimental.
Open Problem 2: Functional correctness verification
Harness Engineering is currently very good at “constraining the Agent from doing wrong things” — architectural violations, style drift, context pollution can all be blocked mechanically. But “verifying that the Agent did the right thing” is far from solved.
Even with browser automation, there are clear visual limits. Some bugs only real human users find — misaligned button layouts, animation jank, complex usability issues. The Agent can screenshot, but it can’t read out “this UI feels annoying to use.”
Compiler-class projects have clear correctness standards (GCC torture test either passes or not), but generic SaaS products don’t have that luxury. This gap is currently filled only by pragmatic compromise like “keep human testing on critical paths.”
Open Problem 3: Long-term maintainability of AI-generated code
Greg Brockman raised a question no one has answered: how do you prevent “functional but hard-to-maintain” code from creeping into the codebase?
Agent-generated code accumulates tech debt differently from human-written code. LLMs tend to reimplement existing functionality, style is subtly inconsistent, comments are formulaic, abstraction levels jump around. None of these are bugs individually, but they accumulate into a codebase that’s hard to maintain.
Background cleanup Agents are the current mainstream answer, but they’re more “continuous housekeeping” than “root-level quality assurance.” Do Code Review standards need fundamental adjustment for AI-generated code? No one knows. This is a direction that will see ongoing research over the next year or two.
One Sentence for the Whole Series
If you remember one line from the three posts, let it be this:
The bottleneck isn’t intelligence — it’s infrastructure.
Models will keep getting stronger, but that doesn’t make Harness Engineering less important — quite the opposite. Anthropic’s C compiler project directly demonstrates this: Opus 4.5 could produce a usable compiler, Opus 4.6 could compile the Linux kernel, but each capability tier required redesigning the Harness. The greater the autonomy you can grant the Agent, the better the guardrails have to be.
As Addy Osmani put it:
The rise of AI coding hasn’t replaced the craft of software engineering — it has raised the bar for it.
Those who truly understand “engineering” — not just “coding” — become more valuable, not less. Because in a world where every Agent can write code, “knowing what to write” and “knowing how to make sure it’s written right” are the truly scarce skills.
References
- Harness engineering: leveraging Codex in an agent-first world (OpenAI)
- Harness Engineering deep dive (Meta / Zhihu)
- Harness Engineering best practices: from concept to rollout (Zhihu)
- Harness Engineering: When humans stop writing code (Zhihu)
- Effective harnesses for long-running agents (Anthropic)
- Building a C Compiler with Claude (Nicholas Carlini, Anthropic)
Answers come from this article only. Click any prompt below or open the chat at the bottom right.
🇺🇸 English
If you're not OpenAI and you don't have Codex, how does Harness Engineering actually land on your project? That's the question this final piece is built around. We're going to walk through four things: the recurring failure modes that Agents hit, the context sweet spot you have to respect, the four-pillar framework the industry has quietly converged on, and a three-phase rollout you can literally start this afternoon. Then we'll close with six points of consensus, and three problems no one has cracked yet.
Let's start with the enemy. Anthropic has identified four failure modes that show up no matter which model you use, no matter what harness you've built, no matter what task you throw at it. As soon as you let an Agent run autonomously, these appear.
The first is one-shotting — the Agent tries to finish everything in a single turn. Halfway through, the context window runs out. Next session, it wakes up to a half-finished codebase with no notes, and burns enormous tokens trying to figure out what past-self was doing. It's the Agent equivalent of blacking out and waking up somewhere unfamiliar.
The second is declaring victory too early. Late in the project, the Agent looks around, sees decent progress, and calls it done — even though real functionality is still missing. It picks whatever "feels roughly complete" instead of verifying against the original spec.
The third is closely related — marking features done too early. Unit tests pass, the API returns something on curl, TypeScript compiles, so the Agent flips the flag to done. But there's a huge gap between that and a user actually being able to use the feature.
The fourth is the environment cold-start tax. Every new session, the Agent spends a fortune in tokens just figuring out how to run the project, which port, how the database connects — instead of doing real work.
All four share one root cause: Agents have no structured working memory and no clear completion criteria. The job of Harness design is to solve this at the system level, not paper over it with a slightly better prompt each time.
Now, before we get to the framework, one concept has to click first: more context is not better. This is counterintuitive — surely more information helps? — but every observation points the other direction. Take a 168K context window. Performance starts collapsing around 40% utilization. Below 40% you're in the Smart Zone: focused, accurate reasoning. Above 40% you're in the Dumb Zone: hallucinations, loops, malformed tool calls, garbage code.
And here's the wild part — experiments show that just changing the tool interface format of the Harness can move the same model from single-digit benchmark scores to over 60%. Weights untouched. LangChain reported similar effects — Harness improvements alone moved the same model from 30th to 5th on Terminal Bench 2.0. So before you agonize over Claude versus GPT, look at your Harness. Cramming MCP tools and verbose docs and dialogue history into the Agent doesn't make it smarter — it shoves it straight into the Dumb Zone. Context is a scarce resource. Spend it carefully.
Okay, four pillars. This is what OpenAI, Anthropic, Stripe, and independent teams like Hashimoto's Ghostty work have all converged on, each pillar directly countering one of those failure modes.
Pillar one: Context Architecture. The Agent should get exactly the context it needs — no more, no less. Every team independently discovered that dumping all instructions into one file doesn't scale. What emerged is a three-tier structure. Tier one is session-resident, auto-loaded every time — that's your AGENTS.md, a project overview, a few hundred tokens max. Tier two is on-demand, loaded when specific sub-agents or skills get invoked — specialized contexts, domain knowledge. Tier three is a persistent knowledge base the Agent only queries when it actually needs to — research docs, historical sessions, that error-code manual you use 5% of the time. The insight is simple: not all knowledge deserves to be loaded at session opening.
Pillar two: Agent Specialization. Focused Agents with restricted tools outperform generalist Agents with full permissions. Sounds backwards — isn't a specialized Agent more limited? Two reasons. First, cleaner context means it stays permanently in the Smart Zone. Second, smaller tool permissions mean smaller error blast radius. A read-only Agent can't accidentally delete files. So in practice you split roles: a Research Agent with read-only tools; a Planning Agent, also read-only, that decomposes requirements; an Executor Agent with scoped write permissions; a Reviewer Agent that flags issues; a Debugger Agent that fixes what the reviewer finds; and a Cleanup Agent to fight entropy. Anthropic's C compiler project split roles into compiler core, dedup, performance, and docs. The dedup Agent exists specifically because LLMs love reinventing wheels — you need a dedicated context-manager to stop that.
Pillar three: Persistent Memory. Progress lives on the filesystem, not in the context window. Agents have no real memory — every session starts from zero. So instead of hoping it remembers, force it to write progress into files. Anthropic's pattern is worth copying: a two-stage architecture. An Initialization Agent runs once, producing three artifacts — an init.sh startup script, a progress log, and a structured feature list in JSON. Then every session, the Executor Agent follows a fixed SOP: check the working directory, read the git log and progress file, pull the highest-priority unfinished feature from the JSON, run init.sh to bring up the environment, verify baseline tests, then start work. That single SOP solves the cold-start tax, kills the "declaring victory" problem because there's a checklist to verify against, and prevents one-shotting because each session picks exactly one feature.
One detail worth remembering here — track feature status in JSON, not Markdown. Markdown is too soft; the Agent will happily flip a checkbox from empty to checked without actually doing the work. JSON has that schema-feel; the Agent hesitates before mutating it. Using data-structure rigidity to substitute for prompt softness — that's a classic Harness technique.
Pillar four: Structured Execution. Separate thinking from execution. Understand, plan, execute, verify — four phases, deliberately kept apart. Cloudflare's Boris Tane said it plainly: never let the Agent write code before you've reviewed and approved a written plan. Why? Because reviewing a plan is much faster than reviewing five hundred lines of code. If the spec is right, implementation follows. If the spec is wrong, you catch it before the damage is done. That's why every serious Agent tool — Cline, Claude Code, Aider — ships a Plan Mode versus Act Mode toggle. It's not a gimmick.
Alright, framework's clear. Where do you actually start? Harness Engineering is incremental. Teams that try to build all the infrastructure at once fail. Here's a three-phase path.
Phase one is the information layer, and you can start this afternoon. One job: move project knowledge out of Slack and Google Docs and people's heads, into the git repo. Write a 50 to 100 line AGENTS.md in map mode, then distribute details into structured directories — docs/architecture, docs/conventions, docs/plans. The payoff is immediate — the Agent starts producing on-team-style code because it can finally see your conventions. Critical warning: do not let AGENTS.md exceed 100 lines. You'll be tempted to write every rule into it. Resist. Beyond that, you're violating the 40% rule.
Phase two is the constraint layer — three to five days of work — and this is the real inflection point. Phase one lets the Agent know the rules. Phase two makes it so the Agent can't help but follow them. Translate verbal conventions into linter rules and CI checks. Here's a useful heuristic: if a rule has come up in Code Review more than three times, it should be a linter rule. Handle three to five per week. Soon you'll notice Code Review shifting from arguing about style to discussing actual design. And every linter error message should follow a three-part structure: what's wrong, how to fix it — ideally with a code snippet — and where to read more. Every linter rule you write is essentially a prompt. When you design error messages, treat the Agent as your user, not as a coworker.
Phase three is the automation layer — one to two weeks — and it's a nice-to-have for long-term projects. This is when the Agent starts the app itself, screenshots to verify, queries logs to debug. Three key moves: Git Worktree isolated verification so multiple PRs can run without stepping on each other; a background cleanup Agent doing scheduled doc-gardening, dead-code sweeps, duplicate-implementation detection; and observability wiring, so the Agent can query logs and metrics. Payback period is longer here — appropriate for projects that are stable and committed to long-term maintenance. Don't rush into this for a project you just launched.
Now, six points of industry consensus — multiple independent teams arriving at the same conclusion.
One: the bottleneck is infrastructure, not model intelligence. Before you switch models, examine your Harness. Order-of-magnitude better ROI.
Two: docs are a live feedback loop, not a static artifact. Every line of AGENTS.md should correspond to a past Agent failure. Update the doc every time the Agent errs, so the same error never happens twice. Docs are operating manuals for Agents, not monuments for humans.
Three: separate thinking from execution. Iron law. Never let the Agent write code before you've reviewed a written plan.
Four: more context is not better. Past 40%, you're in the Dumb Zone.
Five: constraints must be enforced mechanically, not merely documented. OpenAI's phrasing is blunt: if it cannot be enforced mechanically, agents will deviate. Linters and CI are standard, not optional.
Six: the engineer's role is shifting from writing code to designing environments and managing work. Code quality has become a system property, not a personal virtue. Discipline lives in the tools and structures, not in the code itself.
Now the honest part — three problems no one has cracked yet.
First: retrofitting brownfield projects. Every publicly reported success story is greenfield, or a Harness built from scratch. For a ten-year-old codebase with inconsistent tests and stale docs, there's no proven methodology. Martin Fowler compared it to turning on strict linting for code that's never been linted — you get drowned in warnings. Possible directions exist — start with one module, do an AI code archaeology pass first, loosen thresholds and tighten gradually — but they're all experimental. This matters because most teams are brownfield.
Second: functional correctness verification. Harness is very good at stopping the Agent from doing wrong things. It's still bad at verifying the Agent did the right thing. Even with browser automation there are visual limits. The Agent can screenshot but it can't feel that a button layout is annoying, or that an animation is janky. Compiler projects have clear correctness standards — either the torture test passes or it doesn't. Generic SaaS doesn't have that luxury.
Third: long-term maintainability of AI-generated code. Greg Brockman raised this one, and no one has a great answer. Agent code accumulates tech debt differently — subtle style inconsistency, formulaic comments, abstraction levels that jump around, tendency to reimplement things. Each item is not a bug. Together they become a codebase that's hard to maintain. Background cleanup Agents help, but they're housekeeping, not root cause. Does Code Review need fundamentally different standards for AI code? Nobody knows yet.
So — three takeaways to land the plane.
First: the bottleneck isn't intelligence, it's infrastructure. If you remember one line from this whole series, let it be that. Fixing the harness is nearly always higher ROI than swapping the model.
Second: context is a scarce resource. The 40% rule, three-tier context architecture, specialized agents — all of it flows from that single premise. Progressive disclosure beats cramming.
And third: as models get stronger, the harness matters more, not less. Anthropic's C compiler project makes this concrete — Opus 4.5 built a usable compiler, 4.6 compiled the Linux kernel, but each capability jump required redesigning the harness. The greater the autonomy you grant, the better the guardrails have to be. In a world where every Agent can write code, knowing what to write and knowing how to make sure it's written right — those are the skills that get scarcer.
🇹🇼 中文
前兩集我們聊了 Harness Engineering 的概念,還有 OpenAI 怎麼用 Codex 打造百萬行程式碼的產品。這一集要換個視角,回答一個更實際的問題——如果你不是 OpenAI,也沒有 Codex,這套方法論到底怎麼落到你自己的專案上?
我會分四段來談:Agent 的固定翻車姿勢是什麼、上下文的甜蜜區間、業界收斂出的四大支柱、還有三階段落地路線圖。最後點出六大共識,跟三個到現在還沒解的難題。
好,先講敵人。Anthropic 在大量長時運行 Agent 的實踐裡,整理出四種反覆出現的失敗模式,不分模型、不分 harness、不分任務——只要放任 Agent 自主跑,它們就會出現。
第一種叫「試圖一步到位」。Agent 有個很強的傾向,想在一輪對話裡把整件事做完。結果做到一半 context window 就爆了,下一個 session 啟動時看到的是半成品、沒文件的程式碼,只能花大量 token 猜「之前發生了什麼」。這其實就是 Agent 版的昨晚喝斷片、早上不知道自己在哪。
第二種是「過早宣布勝利」。專案後期部分功能完成後,Agent 會環顧四周,看到有進展就直接宣布任務完成——即使還有一堆功能沒做。它傾向於挑感覺差不多的狀態當終點,而不是對照原始規格逐項驗證。
第三種是「過早標記功能完成」。單元測試過了、curl API 有回應、TypeScript 編譯過——Agent 就覺得完成了。但這跟「使用者能正常操作」中間差了十萬八千里。
第四種叫「冷啟動稅」。每次新 session,Agent 都要花大量 token 搞清楚這專案怎麼跑、開發伺服器在哪個 port、資料庫怎麼連。每次都在交這筆稅。
這四個問題有一個共同根源——Agent 缺乏結構化的工作記憶和明確的完成標準。Harness 的核心任務之一,就是讓這些問題在系統層面被解決,而不是每次靠 prompt 補救。
再來,進框架之前還有一個關鍵觀念——上下文不是越多越好。這聽起來反直覺,但業界的觀察一致指向同一個方向。以 168K token 的 context window 為例,大約用到 40% 就開始走下坡。前 40% 是 Smart Zone,Agent 聚焦、推理準確;超過 40% 進入 Dumb Zone,開始幻覺、循環、工具呼叫格式錯誤、程式碼品質下滑。塞更多 token 反而傷害性能。
有實驗發現,只改 Harness 的工具介面格式,就能讓同一個模型在編碼基準上大幅提升,有些模型甚至從個位數跳到 60% 以上,權重完全沒動。LangChain 也報告過,用 Harness 改進讓同一模型在 Terminal Bench 2.0 上從第 30 名跳到第 5 名。
所以在你糾結該用 Claude 還是 GPT 之前,先看看你的 Harness 設計。給 Agent 塞一堆 MCP 工具、冗長文件、累積的對話歷史,不會讓它更聰明——只會把它推進 Dumb Zone。40% 不是硬性數字,但方向性是穩定的:context 是稀缺資源,要精打細算地花。
OK,進入業界收斂出的四大支柱。綜合 OpenAI、Anthropic、Stripe、Hashimoto 的 Ghostty 專案這些獨立團隊的實踐,四種模式反覆出現,形成收斂。
第一根支柱是**上下文架構**。核心原則是:Agent 應當恰好獲得當前任務所需的上下文,不多不少。所有團隊都獨立發現,把所有指令塞進一個文件無法擴展,收斂出三層結構。第一層是 session 常駐的,每次自動加載,例如 AGENTS.md、專案結構概覽,只佔幾百 token。第二層是按需加載的,特定子 Agent 被調用時才拉進來。第三層是持久化知識庫,Agent 主動查詢時才讀,像研究文件、規格說明、歷史 session。關鍵洞察是:不是所有知識都值得 session 開場就加載,有些東西 Agent 一輩子只用得到 5%,放進第三層需要時查詢,比放第一層划算得多。
第二根支柱是 **Agent 專業化**。核心原則是:專注特定領域、擁有受限工具的 Agent,優於擁有全部權限的通用 Agent。乍看違反直覺,但原因有兩層:一是上下文更乾淨,專業化 Agent 永遠運行在 Smart Zone 內;二是工具權限更小、犯錯範圍更小,只給讀權限的 Agent 不會意外刪檔。實務上就是明確的角色分工——研究 Agent 唯讀、規劃 Agent 唯讀、執行 Agent 限定範圍讀寫、審查 Agent 唯讀加標記、調試 Agent 限定範圍修復、清理 Agent 帶回滾的讀寫。Anthropic 在 C 編譯器專案裡就把 Agent 拆成核心編譯、去重、性能優化、文件四類——去重 Agent 的存在,就是因為 LLM 有「重新發明輪子」的傾向,需要專人處理。
第三根支柱是**持久化記憶**。核心原則是:進度持久化在檔案系統上,而不是上下文窗口。Agent 沒有真正的記憶,每次新 session 都從零開始。所以與其寄望它能記住,不如強迫它把進度寫進檔案,下次自己讀回來。Anthropic 的做法很值得抄,是一個兩階段架構。初始化 Agent 只跑一次,產出三件事:init.sh 啟動腳本、claude-progress.txt 進度日誌、還有 JSON 格式的結構化功能清單。執行 Agent 每次 session 都跑一個固定的機械 SOP——先 pwd 確認目錄、讀 git log 和進度文件、讀 JSON 選最高優先級的未完成功能、跑 init.sh 拉起環境和測試、最後才開始新開發。這個 SOP 一次解決三種翻車姿勢:冷啟動稅被 init.sh 直接搞定、過早宣布勝利被 JSON 清單擋下、一步到位被「每次只選一個功能」的紀律壓制。
這裡有個實務細節值得記——用 JSON 格式追蹤功能狀態比 Markdown 有效得多。因為 Markdown 太自由,Agent 會不小心把方括號空白改成打勾又沒真的做;JSON 有 schema 感,Agent 動之前會三思。用資料結構的剛性替代 prompt 的柔性,是 Harness Engineering 的經典手法。
第四根支柱是**結構化執行**。核心原則是把思考跟執行分離。理解、規劃、執行、驗證,必須是刻意分開的四個階段。Cloudflare 的 Boris Tane 說得最直接:永遠不要讓 Agent 在你審查和批准書面計畫之前寫程式碼,這種規劃跟執行的分離,是他做的最重要的一件事。背後的邏輯很清楚——審查計畫遠比審查程式碼快。規格對了實作自然可靠;規格錯了,你在 500 行程式碼被生成之前就攔下來,而不是事後才發現方向錯了。這條原則有個推論:規劃階段人類要重度介入,執行階段才能完全放手。Cline、Claude Code、Aider 內建的 Plan Mode / Act Mode 切換,不是花招,就是這條原則的工程化。
四大支柱講完,接下來是最實際的問題:從哪裡開始。Harness Engineering 不是一把梭,而是漸進式的。很多團隊失敗就在想一次做完所有基礎設施。
Phase 1 是資訊層,下午就能開始。只做一件事——把散落在 Slack、Google Docs、腦袋裡的專案知識,搬進 git repo。用地圖模式寫一個 50 到 100 行的 AGENTS.md,然後把細節分散到 docs/architecture、docs/conventions、docs/plans 這些結構化目錄。收益很直接:Agent 開始能穩定產出符合你團隊風格的程式碼。這裡有個關鍵警告——AGENTS.md 不要超過 100 行。超過就是在挑戰上下文上限,違反 40% 法則。你會忍不住想把所有規則都寫進去,忍住。
Phase 2 是約束層,大概 3 到 5 天,這才是真正的質變點。Phase 1 讓 Agent 知道規則,Phase 2 讓 Agent 不得不遵守規則。核心動作是把口頭約定翻譯成 Linter 規則跟 CI 檢查。有個很好用的判斷法則:如果一條規則在 Code Review 中被提過三次以上,就應該寫成 Linter 規則。從最痛的那條開始,一週處理三五條,很快你會發現 Code Review 的內容從「風格問題」轉向「設計問題」。每一條 Linter 錯誤訊息都要遵守三段式——什麼錯了、具體怎麼改(最好給程式碼片段)、去看哪份文件。你寫的每條 Linter 規則,本質上都是一個 prompt。設計錯誤訊息時,把 Agent 當使用者,不要當同事。
Phase 3 是自動化層,1 到 2 週,這才是量變到質變的地方。當 Agent 能自己啟動應用、截圖驗證、查日誌排錯,人類工程師才真正從審查者變成兜底者。這階段有三個關鍵動作:用 Git Worktree 隔離驗證,讓 Agent 在獨立環境跑 PR;後台清理 Agent 定期做文件園藝、dead code 掃描、重複實作偵測;可觀測性接入,讓 Agent 能查 LogQL、PromQL 或至少讀本地 log。Phase 3 投入回報週期比較長,適合已經穩定運轉幾個月、確定要長期維護的專案,新專案不用急著做這一層。
再來講六大業界共識。這六點在多個獨立團隊、獨立實踐中得出相同結論。
共識一:瓶頸在基礎設施,不在模型智能。在換模型之前先審視 Harness,投資報酬率通常高一個數量級。
共識二:文件必須是活的回饋循環,不是靜態制品。AGENTS.md 每一行都應該對應一個歷史 Agent 失敗案例。文件不是給人看的紀念碑,是給 Agent 用的操作手冊。
共識三:思考跟執行必須分離。永遠不要讓 Agent 在你批准書面計畫之前寫程式碼,這是所有團隊獨立發現的鐵律。
共識四:上下文不是越多越好,超過 40% 就進入 Dumb Zone。
共識五:約束必須機械化執行,不能只靠文件記錄。OpenAI 的原話很直接——如果無法機械化強制執行,Agent 就會偏離。Linter、CI、結構測試是標配,不是選配。
共識六:工程師角色正在從「寫程式碼」轉向「設計環境跟管理工作」。程式碼品質從個人修養變成系統屬性。紀律不再體現在程式碼本身,而是在支撐結構、工具、抽象跟回饋迴路裡。
這六條可以當成 Harness Engineering 的檢核清單——當你做的決定違反其中一條,通常代表方向有問題,該停下來檢查。
當然,也有三個目前業界都還沒解的難題。
第一個空白是**棕地專案的改造**。所有公開的成功案例都是綠地。對於一個十年歷史、沒架構約束、測試不一致、文件殘缺的舊 codebase,怎麼漸進引入 Harness?目前零成功案例、零方法論。Martin Fowler 把這比作在從未用過靜態分析的 codebase 上啟用嚴格 Linter——你會被警報淹沒到什麼都改不動。可是大多數團隊面對的都是棕地。可能的方向包括從單一模組做起、先用 AI 做程式碼考古再建規則、或引入時暫時放寬閾值再逐步收緊,但這些都還在探索。
第二個空白是**功能正確性驗證**。Harness 很擅長「約束 Agent 不做錯事」,但「驗證 Agent 做對了事」遠沒解決。即使有瀏覽器自動化,有些 bug 只有真人才能發現——按鈕排版錯位、動畫卡頓、複雜的可用性問題。Agent 可以截圖,但它讀不出「這個介面用起來很煩」這種感受。
第三個空白是 **AI 生成程式碼的長期可維護性**。Greg Brockman 拋出過一個至今無人回答的問題——怎麼防止「功能沒問題但可維護性很差」的程式碼滲透進 codebase?Agent 傾向重新實作已有功能、風格微妙不一致、註解偏形式化、抽象層次跳動。這些單獨看都不算 bug,累積起來就會讓 codebase 難以維護。後台清理 Agent 是目前的主流答案,但它更像持續打掃,不是根本性的品質保證。
好,這個三集系列如果只記一句話,那應該是——**瓶頸不在智能,而在基礎設施**。
模型會繼續變強,但這不會讓 Harness Engineering 變得不重要,恰恰相反。Anthropic 的 C 編譯器專案就印證了:Opus 4.5 能產出能用的編譯器,Opus 4.6 能編譯 Linux 核心,但每個能力等級都需要重新設計 Harness。能給 Agent 的自主空間越大,護欄就得越好。
正如 Addy Osmani 說的——AI 編碼的興起沒有取代軟體工程的工藝,它抬高了工藝的門檻。那些真正理解「工程」而非只擅長「編碼」的人,價值不是下降了,是上升了。
最後三個核心要點收尾:第一,Agent 有四種固定翻車姿勢——一步到位、過早宣布勝利、過早標記完成、冷啟動稅,Harness 要在系統層面解決,不是靠 prompt 補救。第二,記住 40% 法則和四大支柱——上下文架構、Agent 專業化、持久化記憶、結構化執行,這是業界收斂出的框架。第三,落地要漸進式——資訊層、約束層、自動化層,別想一次做完,Phase 2 才是真正的質變點。在一個 Agent 都會寫程式碼的世界裡,「知道該寫什麼」跟「知道怎麼確保寫對」,才是真正稀缺的能力。
Tags
Related Articles
Harness Engineering (2): Five Engineering Answers from OpenAI's Million-Line Experiment
Three OpenAI engineers, five months, one million lines of AI-generated code, zero hand-written. The real value of this experiment isn't the numbers — it's the proof that Harness design can be engineered. Five concrete practices: making the app legible to agents, treating the repo as the source of truth, mechanizing architectural constraints, rewriting merge philosophy, and background entropy management.
Headroom: The Local Layer That Strips 90% of Your Context Before It Hits the LLM
Headroom compresses tool outputs, logs, and RAG chunks by 60–95% locally, before the request reaches your provider. The part worth stealing isn't the ratio — it's how it decides whether to compress at all using 'mask extraction + cache-mutation economics' — plus a reminder that its docs run ahead of its code.
Sakana Fugu vs OpenRouter Fusion: Two Ways to Wrap a Multi-Agent System in a Single Model
Two 2026 products answering the same question: when a single model hits its ceiling, don't pick one model — orchestrate a pool of them behind one API. Fugu bets on learned coordination; Fusion bets on parallel deliberation plus a judge.