Skip to content
be-human.ai
← Back to the journal

Harness fundamentals

Agent Harness Design: Set Retry Limits and Tool Budgets

How to set retry limits, tool-call budgets and stop conditions in an AI agent harness so a stronger model cannot loop without bounds.

Be Human typographic cover with the title: Agent Harness Design: Set Retry Limits and Tool Budgets
Conceptual illustration created with AI · Be Human

A good agent harness sets three limits before the model runs: how many times a failed step may be retried, how many tool calls a single task may make, and which conditions force the run to stop and hand off to a person. A more capable model does not remove the need for these limits, because extra reasoning often shows up as more attempts, more tool calls and longer chains of self-correction. The goal is a harness where every retry, call and stop condition has a number, an owner and a log entry.

Key takeaways

  • Give every retry a cap, a wait rule and a short list of error types that are allowed to retry.
  • Budget tool calls per task and per tool, counted by the harness rather than by the model.
  • Make each stop condition observable, so every halted run records a reason code and a final state.
  • Make write actions idempotent or state-checked before any retry is allowed on them.
  • When a budget runs out, escalate to a person instead of letting the model try again.

Why a more capable model needs tighter limits

A stronger model changes what the harness has to guard against. It plans further ahead, notices more ways to recover from a failed call, and is more willing to try another route when the first one fails. Each of those strengths becomes cost or risk when nothing outside the model sets a boundary. The model does not know your rate limits, your spend ceiling, or that a record was already updated on the previous attempt. Those facts belong to the harness.

So the numbers should live in the harness, not in the prompt. For each task, define the maximum attempts for each failing step, the maximum tool calls for the whole run, the maximum elapsed time, and the conditions under which the run stops. A prompt can ask the model to be efficient, but a prompt cannot count. Keep that distinction in mind through the rest of this guide.

How do you set retry limits by error type?

Not every failure deserves a retry. Sort errors into three groups before writing any retry logic.

  • Transient errors, such as a timeout or a temporary refusal from a service, may retry with a short, increasing wait and a small fixed cap.
  • Input errors, such as a validation failure on a field the model filled in, should return to the model once with the validation message, not be retried unchanged.
  • Permission and policy errors, such as a request outside the granted scope or a missing approval, should never retry. They stop the run and escalate.

Set the attempt cap per tool, because a read-only lookup can tolerate more attempts than an action that sends a message to a customer. Then add a total retry cap for the whole run. Without it, five steps that each retry twice can quietly become a long chain of calls that no single rule ever flagged. Anthropic's guidance on building effective agents favors simple, composable patterns and adding complexity only where it clearly helps, which applies directly to retry logic: it is code you will maintain, so keep the rules few and easy to read.

The harness should store the attempt count with the run record, so that a reviewer can see after the fact which step failed, how many times it was tried, and why the run ended.

How do you budget tool calls per task and per tool?

Tool-call budgets work at two levels. The task budget caps the total number of tool calls a single run may make. The tool budget caps how many times one tool may be called inside that run, and sometimes how many times it may be called in a day. Both are counters the harness keeps and enforces.

Size the budgets from the work, not from a generous default. Write down the expected path for one normal task: how many lookups, how many writes, how many messages. Then set the budget at a small multiple of that path. If a normal run needs one lookup and one update, a budget that allows dozens of lookups is not a budget at all. Review the figures after the first weeks of logs, and raise a limit only with a recorded reason. The guide on token and step budgets with alerts covers how to pair these counters with warnings that arrive before the hard stop.

When the budget is spent, the harness should not grant more calls. It should return a structured message that names the exhausted tool and the partial state, then either complete with a clearly marked partial answer or escalate. The model should be told the budget is gone, because a model that does not know may keep planning calls that will be refused.

Which stop conditions can the harness check without asking the model?

A stop condition is useful only if the harness can evaluate it independently of the model's reasoning. Practical examples include: the attempt cap for a step is reached, the task budget is spent, the same tool is called twice with identical arguments, the elapsed time passes its limit, a policy check fails, or a required tool is unavailable.

The model's own report that it cannot finish is a signal, not a stop by itself. The harness should treat it as a request to escalate, because a model that says it is stuck may still attempt another route. Each stop should write a reason code to the log and move the task to one defined final state, such as completed, partial, or waiting for a person. The companion guide on stop conditions for AI agent loops describes how to choose which conditions halt a run and which only raise a warning.

Illustrative scenario: an agent answers order-status questions for a small online shop. Its lookup tool returns a validation error for an order number format the agent has not seen before. Without limits, the model rewrites the number in several ways, calls the lookup again each time, and then begins searching by customer email across many pages. In the harness described here, the lookup tool allows two attempts, the input error returns once to the model with the validation message, a repeated identical call stops the run, and the total call budget for the normal path is small. The customer receives an honest status message, and the case goes to a person with the order text and the reason code attached. The values are illustrative configuration choices, not measured results.

How do you make retries safe for actions that write data?

Retrying a read is usually harmless. Retrying a write can duplicate a refund, a booking or a message. Before any write tool is allowed a retry, it needs an idempotency mechanism or an equivalent state check.

The idempotency approach works like this: the harness generates a key for each intended action and sends it with the request. If the same key arrives again, the receiving system returns the original result instead of performing the action twice. Stripe documents this pattern for its API, and it is a useful reference even when your tools are internal services. If the downstream system offers no such key, the wrapper should read the current record before any retry, check whether the intended change already exists, and only then write.

A reasonable default is to mark every write tool as no-retry. Enable retries for a write only after the check exists and has been exercised in a staging environment with deliberately failing responses. Treat this as a release step, recorded in the same versioned configuration as the tool definition.

A step-by-step plan for the first harness pass

Use this sequence when you set limits for a new agent or tighten an existing one.

  • List every tool the agent may call and mark each one as read or write.
  • Write the expected path for one normal task and count its tool calls.
  • Set an attempt cap per tool and a total retry cap per run.
  • Classify errors as transient, input or policy, and attach each group to its rule.
  • Define each stop condition with a reason code and a final state.
  • Add an idempotency key or a state check to every write tool before enabling retries for it.
  • Test the limits with broken tools in a staging environment, and confirm that each halt is logged.
  • Review the logs after the first weeks and change a limit only with a recorded reason.

For the monitoring side of these limits, the guide on harness health checks for superintelligent agents shows which signals to watch between reviews. Be Human designs these limits as part of the harness rather than as prompt text. In a first engagement, retry caps, budgets and stop conditions are derived from the defined role, its tools, its approval boundaries and its success criterion, then recorded in versioned configuration. In managed operations, incident response covers runs that hit a limit, and permission review checks whether a budget has grown without a documented reason.

If you are not sure which of your tasks should receive these limits first, the free Be Human AI diagnostic helps you identify the first task worth handing to an agent.

Frequently asked questions

How many retries should an agent get? There is no universal number, and the right cap depends on the tool and the error. Start with a small cap for transient errors only, and set zero retries for write actions until they have an idempotency or state check. Adjust the cap after your logs show which errors actually succeed on a second attempt.

Should the model decide when to stop? The model can report that it is stuck, and the harness should treat that report as a signal to escalate. The stop itself should come from counters, repeated calls, policy checks or elapsed-time limits that the harness evaluates, so the run ends even when the model keeps reasoning. This keeps the decision outside the component most likely to keep trying.

Does a more capable model make budgets unnecessary? No. A stronger model may use fewer calls on a good path, but it also has more ways to justify extra calls on a difficult one. Budgets protect against cost, duplicate writes and slow failures regardless of model quality, and they give the team a fixed point to review when behavior changes.

Where should limits be stored and reviewed? Store them in versioned harness configuration next to the tool definitions, not inside a prompt. Each change should have a stated reason and a reviewer, and the logs should show every run that reached a limit so the team can decide whether the limit is wrong or the task is harder than expected.

Your next step

See where an AI agent fits in your company first.

Take the free Be Human AI diagnostic. A few questions about your work show which task to hand to an agent first, what it needs to know and where a person approves.

Be Human editorial guidance. Examples are illustrative unless explicitly attributed. Sources provide background; implementation choices depend on your workflow.

Less busywork. More room for you.

Bring us the work you wish you had time for.

Book a call to try a personalized AI agent free for 7 days ↗Or take the free AI diagnostic →