AI PM 10X / TECHNICAL FOUNDATIONS
Loops & Harnesses
The engineering scaffold that runs an AI model. The loop is how an agent acts and re-plans, the harness is the runtime around it, and most of an agent's reliability and safety live there rather than in the model.
Overview
A language model on its own can only read text and write text. To make it act, you wrap it in a loop. The model proposes an action, the surrounding code runs that action, the result comes back as an observation, and the model decides the next step. That cycle repeats until a stop condition is met. The code that runs this cycle is the harness, and the cycle itself is the agent loop. The AI Agents page covers what an agent is. This page is about the scaffold that makes one run.
For product managers, the harness is where the real product lives. It manages the context window, decides what the model sees each turn, dispatches tool calls, enforces permissions, handles retries, and sets the conditions that end the loop. The model is one component. Choosing or designing the harness is the decision that determines an agent's reliability, cost, and safety, and those are product decisions as much as engineering ones.
Start here — a 60-minute learning path
Three resources in sequence that cover the concept, the mechanics, and the production runtime
Anthropic · The clearest first-principles account of the agent loop. Read it for the distinction between a fixed workflow and a model that drives its own steps.
Thorsten Ball, Amp · Builds a working agent in about 300 lines so you can see the loop with nothing hidden. The model proposes a tool call, the code runs it, the result goes back in.
Anthropic · Shows what a production harness handles for you. Context management, tool dispatch, permissions, and the gather-act-verify cycle around the model.
Why It Matters for PMs
Reliability lives in the harness
The model is one component. Most of what makes an agent dependable in production comes from the scaffold around it. Tool design, context limits, retries, and stop conditions are all harness decisions, and they are product decisions.
The loop is where cost accrues
Every turn of the loop sends the growing context back to the model and pays for it again. A loop that runs ten steps when three would do is slow and expensive. That is a harness problem, and it is yours to fix.
Control is always by design
A loop with no stop condition runs forever or until it breaks something. Where the loop ends, what needs human approval, and what the agent is allowed to touch are all things a PM specifies up front.
Key Concepts
Three ideas that make an agent run. The loop, the runtime around it, and the rules that end it safely
The agent loop
Propose · Act · ObserveAn agent runs in a cycle. The model proposes an action, often a tool calltool callA structured request from the model to run a function the harness provides, such as searching a database or reading a file. The harness executes it and returns the result. Tool use is what lets a model act on the world rather than only generate text.Anthropic on tool use. The harness runs it and feeds the result back as an observationobservationThe result of an action returned to the model: the search hits, the file contents, the error message. The model reads the observation and decides what to do next. Reason, act, observe, repeat is the ReAct pattern.Prompting Guide: ReAct. The model then decides the next step. The cycle repeats until a stop condition is met.
The harness
Runtime · ScaffoldThe harness is the runtime that runs the loop. It manages the context windowcontext windowThe fixed amount of text a model can read in one turn, measured in tokens. Everything the model knows about the task lives here: the instructions, the conversation so far, and every tool result. When it fills up, the harness has to decide what to keep.Anthropic on context windows, dispatches tool calls, enforces permissions, handles retries and errors, and decides what the model sees each turn. Claude Code and the Claude Agent SDKClaude Code and the Claude Agent SDKAnthropic's framework and tooling for building agents on Claude. It handles the loop, context management, tool dispatch, and permissions so you build on top rather than from scratch. Claude Code is built on it.Claude Agent SDK docs are harnesses. So are open frameworks. The harness is where you make most of your real reliability and safety decisions.
Stop conditions & control
Safe terminationA loop needs a way to end. That comes from a stop conditionstop conditionThe rule that ends the loop: a maximum number of steps, a success check that the goal is met, a budget cap, or an error threshold. Without one, the loop runs until it exhausts resources or causes harm. Setting it is a product decision.Anthropic: building effective agents such as a step limit, a success check, or a budget cap. For consequential actions you add a human approval stephuman approval stepA checkpoint where the agent pauses and a person approves or rejects before it proceeds, for example before sending an email or deleting data. It trades autonomy for safety on the actions that matter most.Human-in-the-loop. Together these decide how the loop ends and what it is allowed to do on the way.
Core building blocks to know
Hover over any term for a plain-English explanation and a link to go deeper.
How an agent runs its cycle
What the model sees each turn
How the loop ends safely
Runtimes that run the loop
In Practice
Four ways loops and harnesses change how PMs scope and ship agentic features
Specify the harness alongside the model
When a team says it is building an agent, the model choice is the smallest part of the decision. The harness is where the work is. What tools the agent gets, how context is managed, where the loop stops, and what needs human sign-off all shape how the feature behaves. Treat those as product requirements you write down, rather than leaving them for whoever wires it up.
Budget the loop before it ships
Each turn of the loop re-sends a growing context and pays for it again. An agent that takes eight steps when three would do is slow and expensive, and your users feel both. Set a step limit and a token budget, then watch real traces to see how many steps tasks actually take. The loop length is a number you can manage, so manage it.
Decide where a human stands in the loop
Reading data is low-stakes. Sending money, deleting records, or emailing a customer is not. Map the agent's actions by how reversible they are, then put an approval step in front of the ones you cannot undo. This is a guardrail you design, and it is far cheaper to add before launch than after an incident.
Build vs buy the harness
Writing a working loop is a weekend project. Making one reliable across context limits, retries, errors, and permissions is not. A maintained harness like the Claude Agent SDK or an open framework handles those for you, while a hand-rolled loop gives you full control and full maintenance. Choose deliberately, because the harness is the part you live with.
Curated Resources
Foundation
Building Effective Agents
20 min readArticle · Anthropic
The reference text on agents. Defines the loop, separates workflows from agents, and gives composable patterns. The cleanest PM-readable starting point on the topic.
How to Build an Agent
25 min readArticle · Thorsten Ball, Amp
Builds a real agent in about 300 lines so you can see the loop with nothing abstracted away. The single best way to understand what a harness actually does.
Building Agents with the Claude Agent SDK
15 min readArticle · Anthropic
Covers the gather-act-verify cycle, context management, tool dispatch, and permissions a production harness handles for you. Reads as the engineering rationale behind a real runtime.
A widely agreed definition of "agent"
8 min readArticle · Simon Willison
A short, sharp piece on what the word actually means now. An LLM running tools in a loop to reach a goal. Useful for cutting through the marketing fog before you spec anything.
Go Deep
ReAct: Synergizing Reasoning and Acting in Language Models
30 min readPaper · Yao et al., Princeton & Google
The paper behind the reason-act-observe loop that most agents run. It showed that interleaving reasoning traces with actions beats either alone on knowledge-intensive tasks.
12-Factor Agents
30 min readArticle · HumanLayer
A set of engineering principles for production agents, drawn from the patterns that actually survive contact with users. Strong on owning your own state, control flow, and context.
Claude Agent SDK – Overview
15 min readDocs · Anthropic
The reference docs for the harness behind Claude Code. Covers the loop, tools, permissions, and context management you would otherwise build yourself.
smolagents – Documentation
20 min readDocs · Hugging Face
A small open framework where agents write their actions as code. A good contrast to the Claude SDK for seeing how different harnesses structure the same loop.
Tool use with Claude
15 min readDocs · Anthropic
How the model requests a tool and how the harness returns the result. This is the single mechanism the whole agent loop is built on, explained at the source.
Videos

Gui Ferreira
The Agentic Loop, Explained: How AI Agents Actually Work
A clear walkthrough of the propose-act-observe cycle and why the loop is what makes an agent feel agentic, more so than the model inside it. The best single explainer of the core idea.

Jeff Su
AI Agents explained in 3 steps
A crisp, non-technical breakdown of what an agent is and how the loop turns a model into something that takes actions. A good five-minute mental model for any PM.

IBM Technology
AI Agents + LLM Reasoning: Transforming Autonomous Workflows
IBM on how reasoning and action combine inside the loop, and how that changes what autonomous workflows can do. Reputable and well-illustrated.

BioinfQuests
ReAct Design Pattern for AI Agents (Reason–Act–Observe)
A focused look at the ReAct pattern itself, the reason-act-observe cycle that sits under most harnesses. Helpful once the high-level idea has clicked.

Frazer Dourado
How to build an AI Agent with Just a Prompt + a Loop
A hands-on build that strips the agent down to a prompt and a loop, which is the clearest way to see that the loop is the whole trick.

IndyDevDan
Build your Claude Code SDK Custom Agents
A practical tour of building on a real harness with the Claude Agent SDK, showing what the runtime gives you versus what you still own.
Key Takeaway
The model is one part of an agent. The harness around it runs the loop, manages context, and enforces the stop conditions and permissions that decide whether the thing is reliable and safe. Spec the harness with the same care you give the model, because that is where the product actually lives.