Skip to content
OpenAgentsbeta
text
1# Tool Budget Guard
2
3Three budgets, checked continuously, with a defined ending when one runs out.
4
5## The budgets
6
7| Budget | Guards against | Default |
8|---|---|---|
9| Tool calls | Loops and thrash | `max_tool_calls` (40) |
10| Wall clock | Hangs and slow crawls | `max_wall_clock_s` (900) |
11| Tokens | Context bloat, cost | 70% of the context window |
12
13Track all three from the first step. Report them at the end whether or not one was
14hit. A task that finished at 38 of 40 tool calls was nearly a runaway, and you only
15learn that if the number is visible.
16
17## Checkpoints
18
19Every 25% of the largest budget, stop and answer in one line each:
20
211. What have I actually established since the last checkpoint?
222. Is the remaining budget enough to finish?
233. If not, what is the smallest useful thing I can deliver with what is left?
24
25Answer 1 being "nothing" twice in a row is a stuck loop. Escalate immediately rather
26than waiting for the ceiling.
27
28## Detecting a loop before the budget dies
29
30Three signals, any one of which means stop:
31
32- **Repeated call.** The same tool with the same arguments twice in a row.
33- **Repeated error.** The same error text three times, however you varied the call.
34- **No new facts.** Two consecutive checkpoints where question 1 is empty.
35
36The response to a loop is never "try once more." It is to change approach or escalate.
37
38## When a budget is exhausted
39
40Follow `on_exhausted`:
41
42- **report** (default). Stop and deliver partial work. Say what you established, what
43 you did not, what you would do next, and which budget ran out. Never present partial
44 work as complete.
45- **ask.** Same report, then request more budget with a specific number and a reason:
46 "another 20 calls to check the two remaining candidates."
47- **abort.** Stop and roll back any partial side effects you own. Use this where a
48 half-finished state is worse than nothing: migrations, deploys, bulk writes.
49
50Whatever the mode, never silently continue past a budget. A budget you can quietly
51exceed is not a budget.
52
53## Interaction with retries
54
55Retries spend budget. Count them. A retry policy and a budget that do not know about
56each other will burn the whole allowance on one failing call. Cap retries at 3 per
57distinct operation and count each against `max_tool_calls`.
58

Keyboard shortcuts

Focus search
/
Go to Explore
ge
Go to Home
gh
Go to Tags
gt
Go to Collections
gc
Show this help
?
Close suggestions or this dialog
Esc