Agent Harness Tutorial · End to end · Zoom level 3
How we take care of it: tool-call budget
tool-call budget catches more than 8 a trip, 24 a turn.
How we took care of it.
- At most 8 calls a trip and 24 a turn.
- A signature (tool name + sorted arguments) seen a third time means going round in circles.
| It reads | how many tool calls this trip and this turn, and their signatures |
| Kind | rule |
| Provided by | harness |
| If it fails | stop the turn |
| Where in the code | plan.over_fan_out() · H loop/plan.py |
| Runs at | 4 · Before the tool |
Real exampleEnds are named tool_call_budget_exhausted and oscillation_detected.
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.
def signature(name: str, arguments: dict[str, object]) -> tuple[str, str]:
"""A call's identity for oscillation purposes: the tool and its arguments."""
return name, json.dumps(arguments, sort_keys=True, default=str)def over_fan_out(asked: int, so_far: int, budgets: Budgets) -> str | None:
"""`per_step` or `per_turn`: the bound a plan of `asked` calls would pass, after
`so_far` calls already planned this turn; `None` when it passes neither."""
if asked > budgets.max_tool_calls_per_step:
return "per_step"
if so_far + asked > budgets.max_tool_calls_per_turn:
return "per_turn"
return None