HOUSSEIN.IA
Free guide · AGENT
Harness, Loop, Graph: the 3 ways to build an AI agent that works
Sent! Open the email I just sent you and click the button to open your guide. Not there within 2 minutes? Check your spam or Promotions tab.
The carousel guide: what each word means, how each one works with a concrete example, which one to pick for your business, and the official sources to go further. Plus 3 instructions to paste into Claude to design your own agent.
3ways to build an agent: Harness, Loop, Graph
5workflow patterns described by Anthropic (routing, parallelization…)
9official sources, all opened on 25 Oct 2026
The 3, one by one
- The idea in 30 secondsWriting a good instruction was step one. Behind an agent that actually works, there are three more things. The Harness decides what the model sees and what it is allowed to touch. The Loop decides when the agent keeps going and when it stops. The Graph decides which step runs next, and where a human has to say yes. Most teams do one of them by accident. The best teams design all three on purpose.
- Harness 1/3: what the model seesThe harness is everything you build around the model. Part one: its context. An instructions file read at every session (CLAUDE.md for Claude Code, AGENTS.md for most other tools), its memory of past sessions, and the right documents at the right time. Anthropic sums up the rule: give the model the smallest set of truly useful information, not everything you have. Business example: a support agent does not need your whole Drive, only your refund policy and your 20 standard answers.
- Harness 2/3: what it can touchPart two: its tools and limits. The list of tools it can call, an isolated space to run things safely, and permissions that make it ask before a risky action (sending an email, paying, deleting). In Claude Code these rules are set tool by tool: reading a file goes through without asking, running a command or editing a file asks for your approval.
- Harness 3/3: how its work gets checkedPart three: the sensors. Tests that say whether it works, checks on the output format, and a trace of every step to understand what happened. A key point from the Claude Code docs: an instructions file is advice, not a barrier. To make a rule always apply, you use a hook, a command that runs automatically at a precise moment (before a tool, at the end of a task). Same model, better harness: better agent.
- Loop: stop steering every stepFor Anthropic, an agent is a model using tools in a loop, looking at the result of each action. Designing the loop means setting three things: a clear goal ("all tests pass", "all 50 records are filled"), a check after every pass, and a hard stop (a maximum number of passes, a time limit, a budget). The simplest version is called the Ralph technique: run the same agent on the same instructions file, pass after pass, and improve those instructions after every mistake.
- Loop: memory between passesEvery pass starts with a fresh context: the agent forgets everything. The method Anthropic published for long tasks: a progress file where the agent writes what is done, a git commit at every pass so you can roll back, and a task list where everything starts as "to do" and the agent ticks items one by one without ever deleting any. The instruction starts the work. The loop finishes it.
- Graph: nodes, edges, shared stateWhen you already know the steps, you do not need to let the model decide everything: you draw the path. Nodes do the work (classify a ticket, search the docs, draft a reply), edges decide what runs next, and a shared state carries the information from one step to the next. Anthropic describes 5 patterns of this kind; the carousel example uses three: routing (refund or question), parallelization (search the docs and past tickets at the same time) and the evaluator (a quality check that sends the draft back if the score is too low).
- Graph: where a human says yesThe big advantage of a graph: you choose exactly where the agent stops to wait for a human. In LangGraph, the best-known tool for this, an interrupt pauses execution, saves the state, and resumes when someone approves. Example: the agent prepares the refund, you click yes. Instructions suggest. Edges enforce.
- Which one for your business?Always the Harness: it is the base of every agent, even the simplest. A Graph when the task comes back often and you know the steps (sorting requests, follow-ups, quotes): it is predictable and easy to control. A Loop when the task is long and open-ended, with a result you can check (filling a file, fixing until everything passes). Anthropic's advice: start with the simplest solution and only add complexity when it truly improves the result.
- Exercise: design your agent in 10 minutesPick a task that eats your time every week. Paste the 3 instructions below into Claude, one at a time, replacing [your task]. You get your agent's harness, loop and graph on paper, before writing a single line.
Prompts to try
I want to hand this task to an AI agent: [your task]. Help me design its harness. Give me 3 short lists: 1) what it should see (instructions, documents, memory) and what it should not see; 2) the tools it can use and the actions where it must ask me before acting; 3) how we check its work is good (tests, checks, traces). Ask me 3 questions first if anything is unclear.
For this task: [your task], design the agent's loop. Give: the exact goal that means "done", the check to run after every pass, the stop conditions (maximum passes, time, budget), and what it should write in a progress file to pick up at the next pass.
For this task: [your task], draw the agent's graph as a list: every node (what it does, LLM or tool), every edge (when it moves to which node), the steps that can run in parallel, where a human must approve, and the information in the shared state. End with a text diagram from START to END.
Links
Anthropic: Building effective agents (the 5 workflow patterns) →Anthropic: Effective context engineering for AI agents →Anthropic: Effective harnesses for long-running agents →Claude Code: CLAUDE.md and AGENTS.md (project memory) →Claude Code: permissions →Claude Code: hooks →AGENTS.md: the open format →The Ralph technique (Geoffrey Huntley) →LangGraph: overview and interrupts →
Want to post your own shorts?
The Machine à shorts makes them for you: a topic goes in, a finished vertical short comes out (script, voice, edit, captions, cover). In Claude Code or Codex, on your computer.
Discover the Machine à shorts →Source reviewed: https://www.anthropic.com/engineering/building-effective-agents on 2026-10-25.