Agent Harness Tutorial · End to end · Zoom level 3
How we take care of it: step and time budgets
step and time budgets catches 12 trips, 60 s, going round in circles.
How we took care of it.
- 12 trips, 60 seconds, and a no-progress check for the same call with nothing new.
| It reads | trips used, seconds used, repeated calls |
| Kind | rule |
| Provided by | harness |
| If it fails | stop the run |
| Where in the code | H config Budgets · H loop/__init__.py |
| Runs at | 7 · After the loop |
Real exampleEach end has its own name in the trace.
More on this: When it stops.
How it is done: the real code
Cut from the live repositories each time the site is built, so it always matches what runs.
class Budgets(BaseModel):
"""Ceilings that can actually stop a call.
Two positions, deliberately. `max_output_tokens` is a per-call backstop at
P3; `max_steps` and `max_cost_usd` are per-task and enforced at P4, because
only the loop can see that fourteen calls are one runaway task rather than
fourteen tasks. AAC-0093 and AAC-0008 are different obligations for exactly
this reason.
"""
model_config = ConfigDict(frozen=True)
max_steps: int = 12
max_cost_usd: float = 0.50
max_output_tokens: int = 4096
max_tool_result_chars: int = 8000
"""Tool results are bounded before they enter context — AAC-0105."""
max_turn_seconds: int = 60
"""Wall clock for one turn (AHC-0096), checked before each step."""
max_tool_calls_per_step: int = 8
"""How many tool calls one step may plan (AHC-0097). A step budget counts
steps, so without this one step asking for fifty look-ups — or fifty
writes — spends one of the twelve and does fifty things."""
max_tool_calls_per_turn: int = 24
"""How many tool calls one turn may plan across all its steps (AHC-0097).
Reaching either bound stops the turn before the step's calls run, as
`tool_call_budget_exhausted` — never a silent cut to the first N (AHC-0059)."""
max_retries_per_unit: int = 4
"""AHC-0024: retries across the whole turn, every call's together (F-087)."""