When an Agent Says It's Done, Look at Its Stop Rules First
Nine Agent patterns plus six harness decisions. Stop conditions, tool menus, memory, crash recovery, permissions, and acceptance—failures often happen outside the model.
An Agent says the task is done, but the tests were never run; it remembers the rules at the start and forgets them twenty minutes later; the same approval pop-up gets clicked for a week. Yarchi recently posted a diagram that compresses common Agent patterns into nine, and also wrote a long article that breaks the layer of software wrapped around the model into six decisions. Here, an Agent means an LLM application that can call tools and execute multi-step tasks continuously; the harness is the loop, tools, memory, persistence, permissions, and acceptance outside the model. Upgrading the model won't solve these problems; if the shell is poorly designed, failures will repeat.
Video from Yarchi's tweet, nine images with one vertical video.
Let's go through the nine patterns first. They are more like a vocabulary, making it easier for teams to align on terminology.
- Prompt chaining: Break a task into steps, with the output of each step fed into the next. Suitable for content pipelines, reports, and processes with a fixed order.
- Routing: First have the model read the request, then route it to the appropriate specialist. Refunds go to billing, bugs go to technical. Suitable for customer service bots, inbox triage, and choosing a cheaper or smarter model based on question difficulty.
- Parallelization: Split the work and run it in parallel, then merge the results. Suitable for multi-source research, reviewing large codebases, and checking the same answer in several ways.
- Orchestrator-workers: The main Agent looks at the task, decides which subtasks are needed, and assigns them to workers. The number of workers can vary each time. Suitable for coding Agents that modify many files and deep research tools.
- Evaluator-optimizer: One model writes, another scores and gives revision feedback, looping until the score is good enough. Suitable for translation, writing in a fixed style, and code that must pass tests.
- ReAct: The Agent thinks one step, takes an action, observes the result, and thinks again. Most coding Agents run on this loop. Suitable for tool-using tasks such as search, browsing, and executing code.
- Plan-and-execute: First write a complete list of steps, then check them off one by one. Suitable for long tasks such as migrations and multi-day projects; use it when the Agent is prone to getting lost.
- Reflection: The Agent rereads its own answer, finds and fixes errors, then hands it to you. Suitable for code, math, and fact-checking, where the first version usually has errors.
- Human-in-the-loop: Stop before high-risk actions and wait for human confirmation. Suitable for payments, deleting data, sending emails, and pushing to production.
Yarchi's advice is to start with the simplest pattern that works. Real Agents mostly stack two or three patterns together.
These nine diagrams are a good entry point. When it comes to actual projects, the harder judgment in his long article is this: you are already using a harness; the difference is whether it was designed. The article gives three company approaches. DoorDash turned the harness into a platform: each Agent runs in a disposable VM, with the repo, tools, and credentials prepared at startup; tasks are written as YAML playbooks that mix Agent steps and ordinary scripts; all internal system calls go through a gateway that only exposes tools declared in the playbook and logs every call. It ran 130,000 automation tasks in a month and more than 25,000 code reviews per week. OpenAI turned the harness into a repository: an instruction file of about 100 lines, used as a documentation index, with architecture rules enforced by custom linters; three engineers merged about 1,500 PRs in five months. Anthropic turned the harness into a division of labor: three Agents—one turns a sentence into a spec, one implements it, and one drives the finished product in a browser and scores it; they communicate only by writing files. It cost $200 for 6 hours, versus $9 for 20 minutes for the version without the harness. Better results, at more than twenty times the price. This trade-off is not often advertised.
There are six specific decisions.
1. Where the Loop Stops
Write a one-sentence definition of done, such as the test suite passes and the app can start. Decide how to handle bad outcomes: restart with a failure note, or freeze and wait for a human. Set a hard limit, whether in rounds or minutes. When running unattended, log every round. Someone manually reviewed 50 public Agent loops and found that only 74% stated a completion criterion, and only 32% retained memory across runs. This is the cheapest item on the checklist and the one most often skipped.
2. How Big Is the Tool Menu
Don't load all tool descriptions at once. When multiple MCP servers are connected, stuffing every tool into the context on every round—even when the task doesn't use them—is costly. A more economical approach is to put tools on disk as files and let the Agent open them on demand. Anthropic gave an example where 150k tokens dropped to 2k. Error messages should also be rewritten to tell the model which field is wrong, what valid values look like, and what to try next. Siemens measured a 37 to 40 point increase in task completion rate, with roughly half the tokens per success. Delete tools that haven't been used in a month. How custom tools are named and grouped affects model behavior; prefixes and suffixes are not just decoration.
3. What to Keep in Memory
Don't fill a million-token context; stop working at 300k to 400k. Clear the window by phase: research, writing docs, planning, implementation; each phase reads only the documents from the previous phase. Facts can be summarized; rules cannot. Pin safety, policy, and hard limits in files, reread them after every reset, and repeat them in the system prompt. If the model accepts five suggestions in a row without pushback, switch to a new window; earlier errors have already been treated as facts. One study measured policy violations: with rules in view, 0; after compression, 30%; for the worst model, 59%; if rules survived summarization, it was still 0. The paper is single-author and unreviewed, so treat the numbers as strong hints.
4. What to Recover From After a Crash
Keep four files in the repo and have the Agent keep them updated: SPEC.md says what to build; you write it, and the Agent does not edit it. PLAN.md lists the steps and acceptance criteria. PROGRESS.md records what's done, what's next, and what has failed. DECISIONS.md is append-only and records each choice and its reason. Commit after every usable change. If there are many features, add a JSON list marking passing or failing. One line from Yarchi's article is blunt: if it isn't in a file, it doesn't exist.
5. What It Can Touch
Restrict writable directories at the OS level, and route network access through a proxy with an allowlist of domains. People get click-fatigued by approval prompts; some data says 93% of prompts are approved. Approval pop-ups are more like latency than a security control. Put a gateway in front of shared systems, expose only tools declared by the task, and log every call. Don't put long-lived credentials in the sandbox; use short-lived tokens scoped to the task. Anthropic says internal permission prompts dropped by 84% after adding a sandbox. Beyond security, it's also less annoying.
6. Who Decides It's Done
The Agent that wrote the code is not well suited to judge whether the code works. Open a separate review session, a new window, without the reasoning that produced the bug. Make the Agent actually run things: drive web apps in a browser, execute commands in the CLI. Build 20 to 50 evals from failures you've already seen. Run each task three times and look at the worst run. A single-run success rate of 75% means only 42% pass all three. Watch for confident errors: after hitting an error, writing a fluent explanation of why the error doesn't matter. In production research, about 70% of these problems are caught by humans; tests miss them.
For a weekend version, do five things first: an instruction file under 100 lines; if the same problem breaks twice, turn it into a linter; four files plus a commit after every usable change; pin the rules that cannot be summarized away; 20 tasks, each run three times, looking at the worst result.
The harness is not free. That Anthropic example cost more than twenty times as much. It's worth it for work you wouldn't otherwise be able to hand off, not for tasks where you just want to save twenty minutes. Write the stop rules and the four files first—each takes an afternoon—and you'll be able to survive the next model release.
References: Yarchi's tweet, How to Design an Agent Harness.
发布时间: 2026-12-06 06:28