cleandataengineering.aiAgent Harness, drawn simply
You are here: End to end › Checks › 7 · After the loop › step and time budgets

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.

Open: 11before loopopen ›Open: 22before modelopen ›Open: 33after modelopen ›Open: 44before toolopen ›Open: 55the toolopen ›Open: 66after toolopen ›Open: 77after loopopen ›Open: 88before replyopen ›It readstrips used, seconds used, repeatedcallsstep and time budgetsrule · harnesspassCarries onfailIf it failsstop the runWHERE IN THE CODE: H config Budgets · H loop/__init__.py
The strip at the top shows every check point where this check runs, in dark.

How we took care of it.

  1. 12 trips, 60 seconds, and a no-progress check for the same call with nothing new.
It readstrips used, seconds used, repeated calls
Kindrule
Provided byharness
If it failsstop the run
Where in the codeH config Budgets · H loop/__init__.py
Runs at7 · 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)."""