An agent budget is a multidimensional limit on work: turns, model calls, tool calls, tokens or cost proxy, elapsed time, retries, subagent fan-out, and repeated states. Provider limits are helpful, but the harness must enforce end-to-end budgets across retries and resumes, producing explicit limited outcomes instead of restarting or pretending completion.
You will implement a budget ledger, define task-specific completion, and detect cycles before they consume an entire allowance.
Store consumption durably. A resume or retry continues the same ledger unless an authorized operator explicitly grants more.
Detect cycles by hashing meaningful state: current goal, selected action, normalized arguments, and key evidence. Repeated identical failures should stop or escalate.
Reserve capacity for verification and cleanup. If a tool can consume the last call but verification requires another, the system may act without proving the result. Allocate by phase: plan, act, verify, report.
Failure injection: Make a tool return “try again later” forever. The failure counter and repeated-state detector should stop well before the outer deadline.
Test every limit individually and in combination, including subagents and queue retries. Assert terminal status and remaining evidence. Verify cancellation stops provider streams and child processes.
Implement a budget ledger with atomic consumption and phase reserves. Property-test that no event sequence can exceed a hard limit.