Today ainotis Join

My notis

ToolingPublished ExplainedAll news from that day

How an agent harness runs a model and enforces limits

A harness is the code that runs a model in a loop, executes its tool calls and applies limits such as allowed tools, turn caps and hooks.

Share

Check our sources · 12 facts from 3 sources
Illustration: A work table with a cutting tool inside a clear safety guard; the green guard and door stand for limits kept around the tool, not inside it.Illustration made with AI for ai notis
source · Illustration made with AI for ai notis; not a picture of what happened

Key points

  1. In Anthropic's Agent SDK the model requests tool calls, and the SDK runs each requested tool and collects the results, repeating until the task is complete.
  2. The SDK documentation says you control whether calls execute: disallowed tools are blocked "regardless of other settings", and a denied tool gives Claude a rejection message.
  3. The loop can be capped by a maximum number of tool-use turns or an estimated spend, which can be passed by up to the cost of one response.

What happened

An agent runs as a loop. In the Claude Agent SDK, Claude evaluates the prompt, calls tools, receives the results and repeats until the task is complete. In that loop the model only requests tool calls: the SDK runs each requested tool and collects the results.

Anthropic's engineering team calls the Claude Agent SDK "a powerful, general-purpose agent harness adept at coding". The harness also carries what the model cannot keep for itself.

Anthropic's post on long-running agents says the core challenge is that agents "must work in discrete sessions", and each new session starts with no memory of the last. Its harness answers with a progress file and git commits, so that a fresh session can see the state of the work.

It also gives the agent a feature list of over 200 items, each marked as failing at the start, and Anthropic's prompt tells coding agents to edit the list only by changing the field that says whether an item passes. The harness is also where limits live.

The SDK documentation says the model decides which tools to call, but you control whether the calls execute, with lists of allowed and disallowed tools and a permission mode. The documentation says disallowed tools are blocked "regardless of other settings", and a denied tool gives Claude a rejection message as the result.

The loop can be capped by a maximum number of tool-use turns or by an estimated spend, which can be passed by up to the cost of one response. Hooks run in the application process, not inside the agent's context window, and a hook that rejects a tool call stops it from executing.

Claude Code's guide says hooks give "deterministic control: certain actions always happen rather than relying on the LLM to choose". Some harness controls themselves use a model: the SDK's auto permission mode uses a model classifier to review actions such as shell commands and network requests.

What it means for you

Our view

A limit is a control only when the harness enforces it. In Anthropic's long-running agent example, coding agents were told in the prompt to edit the feature list only by changing the passes field. That is an instruction, not a control the harness enforces.

A disallowed-tools list, or a hook that rejects a tool call before it runs, is enforced by the harness. Spend caps are estimates and can be overshot by one response. If you run agents at work, list each limit you rely on, mark whether it sits in the prompt or in the harness, and move the important ones into the harness.

It adds no new facts.

Share this story

Your reaction

We count reactions per story and day, never who reacted. The counts help us choose what goes in the monthly issue. If you are signed in, your own page shows yours too.

Check our sources

Every sentence above is checked against these 3 sources.

1 How the agent loop worksClaude Code documentation · 7 facts Open the source archived copy
  1. The Agent SDK documentation says that when you start an agent, Claude evaluates the prompt, calls tools to take action, receives the results, and repeats until the task is complete.

    When you start an agent, the SDK runs the same execution loop that powers Claude Code: Claude evaluates your prompt, calls tools to take action, receives the results, and repeats until the task is complete.
    cite
  2. The documentation's loop description says: "Execute tools. The SDK runs each requested tool and collects the results."

    Execute tools. The SDK runs each requested tool and collects the results. Each set of tool results feeds back to Claude for the next decision.
    cite
  3. The documentation says: "Claude determines which tools to call based on the task, but you control whether those calls are allowed to execute."

    Claude determines which tools to call based on the task, but you control whether those calls are allowed to execute.
    cite
  4. The documentation says disallowed tools are blocked "regardless of other settings", and that when a tool is denied Claude receives a rejection message as the tool result.

    disallowed_tools / disallowedTools blocks listed tools, regardless of other settings. ... When a tool is denied, Claude receives a rejection message as the tool result and typically attempts a different approach or reports that it couldn't proceed.
    cite
  5. The documentation says the loop can be capped with a maximum number of tool-use turns or with an estimated spend in US dollars, and that spend can pass the budget cap by up to the cost of the response that reaches it.

    Toned down to what the source says
    You can cap the loop with max_turns / maxTurns, which counts tool-use turns only. ... You can also use max_budget_usd / maxBudgetUsd to cap turns based on a spend threshold. ... Max budget (max_budget_usd / maxBudgetUsd) | Estimated spend at which the loop stops ... Spend can therefore pass the cap by up to the cost of that one response
    cite
  6. The documentation says hooks run in the application process, not inside the agent's context window, and that a PreToolUse hook that rejects a tool call prevents it from executing.

    Hooks run in your application process, not inside the agent's context window, so they don't consume context. Hooks can also short-circuit the loop: a PreToolUse hook that rejects a tool call prevents it from executing, and Claude receives the rejection message instead.
    cite
  7. The documentation says the auto permission mode uses a model classifier to review actions such as shell commands and network requests, allowing or blocking each one it reviews.

    auto | Uses a model classifier to review actions such as shell commands and network requests, allowing or blocking each one it reviews.
    cite
2 Effective harnesses for long-running agentsAnthropic Engineering · 26 Nov 2025 · 4 facts Open the source archived copy
  1. Anthropic's engineering post of 26 November 2025 calls the Claude Agent SDK "a powerful, general-purpose agent harness adept at coding".

    Published Nov 26, 2025 ... The Claude Agent SDK is a powerful, general-purpose agent harness adept at coding, as well as other tasks that require the model to use tools to gather context, plan, and execute.
    cite
  2. Anthropic's post says the core challenge of long-running agents is that they "must work in discrete sessions", and that each new session starts with no memory of earlier ones.

    The core challenge of long-running agents is that they must work in discrete sessions, and each new session begins with no memory of what came before.
    cite
  3. Anthropic's post describes a progress file and git commits as the way a new session learns the state of the work.

    The key insight here was finding a way for agents to quickly understand the state of work when starting with a fresh context window, which is accomplished with the claude-progress.txt file alongside the git history.
    cite
  4. In Anthropic's post the initializer agent wrote over 200 features as JSON for a claude.ai clone, each initially marked as failing, and Anthropic prompted the coding agents, with strongly worded instructions, to edit the file only by changing the passes field.

    Toned down to what the source says
    In the claude.ai clone example, this meant over 200 features ... These features were all initially marked as failing ... We prompt coding agents to edit this file only by changing the status of a passes field, and we use strongly-worded instructions like It is unacceptable to remove or edit tests
    cite
3 Automate actions with hooksClaude Code documentation · 1 fact Open the source archived copy
  1. Claude Code's hooks guide says hooks give "deterministic control: certain actions always happen rather than relying on the LLM to choose to run them".

    cite

Topics

The morning email

On the mornings we publish: the three top stories and up to four short ones. Free.

We email you a link to confirm. An issue may include one sponsor, always labelled Sponsored · Advertisement. Our emails count opens and clicks, not who made them. Unsubscribe in one click. What we keep