← Table of Contents · Page 264 of 868
BUDGETS AND RESOURCE LIMITS
Part 7 of 9
EXAMPLES
Example 1: A token budget
A run is given 500,000 tokens in total.
After each step the harness subtracts the tokens used, so it always knows how much fuel remains.
At 400,000 tokens used it logs a warning, and at 480,000 it tells the model to wrap up.
Example 2: Per-workspace tracking
A company gives its marketing workspace a shared limit of 200 dollars per day.
Ten agents run there, and each also has a personal limit of 30 dollars.
One agent develops a bug and begins to loop, but it stops at its own 30 dollars, and the workspace total never approaches the shared cap.
Example 3: Graceful termination
A research agent hits its time budget while a search call is in progress.
The harness waits for that call to finish, refuses to start another, and uses its reserved tokens to produce a note that says which sources were read and which were not.
The user receives a partial but useful answer instead of an error message.
Example 4: Bounded retries
A tool call fails because a server is busy.
The harness retries after one second, then two, then four, adding a small random delay each time.
After three failed retries it tells the agent that the tool is unavailable, and the agent either tries a different tool or reports the problem.
PRACTICE LAB CONNECTION
Add the budget tracker to the Resume Review Agent lab from Chapter 65.
Then deliberately trigger the runaway-loop bug from Chapter 68 and test the prompts below against what happens.
Advertisement
Read Aloud:
0:00 / 0:00