Chapter 9How it all fits together
The whole loop, step by step
Start with the cast. The model is the trained program that predicts text: the brain. The prompt, also called the context, is everything the model reads for one reply: the briefing. The harness is the software around the model that builds the briefing, runs the loop and asks your permission: the body. The tools are actions the harness can take when the model asks, such as searching the web, opening a file or sending an email: the hands. And there is you. In this picture you only ever talk to the harness, never to the model directly. Figure 9.1 shows all five, with the steps numbered.
Try it: step through the whole loop, or choose a part to see what it does.
Interactive Step through the loop, or choose a part to see what it does.
Step through it, or pick a part below to see what it does.
- You ask a question.
- The harness builds the briefing: its instructions, your message, notes it keeps and earlier results.
- The model reads the briefing and predicts a reply: either an answer, or a request for a tool.
- For a tool request, the harness checks the rules, asks you if needed, and runs the tool.
- The result goes back into the briefing, and the model reads it again. This loop repeats until the job is done.
- The harness hands the final answer back to you.
Use it in a slide: SVG · PNG (free to use in your own slides and talks, with credit to Steve Sparks and a link to aifromthepartsup.com)
1. You ask. You type a request into an app: a chat window, a coding tool, an assistant inside your email. Whatever it looks like, the app is the harness.
2. The harness builds the briefing. Before the model sees anything, the harness assembles one long document. It holds instructions from the model’s maker and the app’s builder, a list of the tools the model may ask for, any saved notes, the conversation so far, earlier results and, last, your message.12 Chapter 6 called this the stack. Most of it was written by someone other than you.
3. The model predicts a reply. The model reads the whole briefing and predicts what comes next. The reply takes one of two forms. It is either an answer for you, or a structured request for a tool, such as “read the file invoices-june.xlsx.” The model cannot carry the request out. Anthropic’s documentation sums it up in eight words: “The model never runs anything on its own.”34
4. The harness checks, asks and acts. For a tool request, the harness takes over. It checks its rules: is this tool allowed, and is this step risky? If the rules call for it, it asks you first, as some harnesses do, for example, before deleting files.5 Then it runs the tool. For some tools, such as web search, the provider’s own servers do the running.3
5. The result goes back in. Whatever the tool returns is added to the briefing as more text: a page of search results or the contents of a file.36 In this book’s examples, a refusal goes back the same way, as a note that you said no. The model reads the longer briefing and predicts again. It may ask for another tool, and another. Steps 3, 4 and 5 repeat until the model writes an answer instead of a request. Researchers described this pattern of reasoning, acting and observing in 2022 work called ReAct.7
6. The answer comes back. When the model’s reply is an answer, the harness shows it to you. If the app keeps memory, the harness may also save notes from the chat, to add to a later briefing.8 The model itself learns nothing from you along the way. Using a model doesn’t retrain it: when GPT-3’s developers gave it new tasks, they did it “purely via text interaction with the model,” without changing its parameters.9
Lay the lawyer’s case over Figure 9.1. Steps 1, 2, 3 and 6 happened, over and over. In the court’s account, nothing like steps 4 and 5 appears: no lookup, no result, nothing new for the model to read. The checks that worked happened outside the loop, in his own research: he looked for Varghese and could not find it, and later could not locate another of the cases.10
Three more things follow from the loop. A model that uses tools may take several turns for every one of yours. When it decides its own next steps until a task is done, people call the whole arrangement an agent.11 Every tool result is text the model reads, so a web page or document can try to slip in orders of its own, a trick called prompt injection.12 That is one reason step 4 matters; Chapter 8 tells how harnesses defend against it. And at every step your words move: into the briefing, to the company that runs the model, into a tool. Chapter 10 follows them.
Notes (12)
- 1Anthropic, “Effective context engineering for AI agents,” Anthropic Engineering, September 29, 2025, https://www.anthropic.com/engineering/effective-context-engineering-for-ai-agents (accessed October 27, 2026).
- 2Anthropic, “System prompts (release notes),” Claude Platform Docs, https://platform.claude.com/docs/en/release-notes/system-prompts/overview (accessed October 26, 2026).
- 3Anthropic, “How tool use works,” Claude Platform Docs, https://platform.claude.com/docs/en/agents-and-tools/tool-use/how-tool-use-works (accessed October 26, 2026).
- 4OpenAI, “Function calling,” OpenAI API docs, https://developers.openai.com/api/docs/guides/function-calling (accessed October 26, 2026).
- 5Anthropic, “Use Claude Cowork safely,” Claude Help Center, https://support.claude.com/en/articles/13364135-use-claude-cowork-safely (accessed October 26, 2026).
- 6Anthropic, “Handle tool calls,” Claude Platform Docs, https://platform.claude.com/docs/en/agents-and-tools/tool-use/handle-tool-calls (accessed October 26, 2026).
- 7Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, and Yuan Cao, “ReAct: Synergizing Reasoning and Acting in Language Models” (preprint, arXiv, October 6, 2022), https://doi.org/10.48550/arXiv.2210.03629.
- 8Anthropic, “Use Claude's chat search and memory to build on previous context,” Claude Help Center, https://support.claude.com/en/articles/11817273-use-claude-s-chat-search-and-memory-to-build-on-previous-context (accessed October 26, 2026).
- 9Tom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah, Jared Kaplan, Prafulla Dhariwal, Arvind Neelakantan, et al., “Language Models are Few-Shot Learners” (preprint, arXiv, May 28, 2020), https://doi.org/10.48550/arXiv.2005.14165.
- 10U.S. District Court for the Southern District of New York (P. Kevin Castel, U.S. District Judge), “Mata v. Avianca, Inc., No. 22-cv-1461 (PKC): Opinion and Order on Sanctions (ECF No. 54),” No. 22-cv-1461 (PKC), ECF No. 54, June 22, 2023, https://www.courtlistener.com/docket/63107798/mata-v-avianca-inc/ (accessed October 27, 2026). Cited at page 19.
- 11Anthropic, “Building effective agents,” December 19, 2024, https://www.anthropic.com/research/building-effective-agents (accessed October 27, 2026).
- 12Kai Greshake, Sahar Abdelnabi, Shailesh Mishra, Christoph Endres, Thorsten Holz, and Mario Fritz, “Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection,” in Proceedings of the 16th ACM Workshop on Artificial Intelligence and Security (November 30, 2023), 79–90, https://doi.org/10.1145/3605764.3623985.
Chapter 9 · page 3 of 5
Turn pages with the ← and → keys.