PRODUCTION SCENARIO
Your code-audit agent runs on Claude Opus 5 with the task budgets beta enabled. One task takes 30 to 80 tool calls spread over many requests, and your client resends the full uncompacted history on every one of them. Finance wants each task to land near 120,000 tokens, the audit's reasoning depth has to stay where it is, and the agent has to close with a findings summary rather than stop mid-action.
Which configuration meets both goals?
Answering here is anonymous. Nothing is saved unless you sign in.
Show answer and explanation
Answer: A 120,000-token task_budget for pacing, with max_tokens kept as the per-request cap
A task budget gives the model a running countdown across the whole agentic loop and is advisory, so it paces itself and wraps up as the target nears, while max_tokens stays the enforced per-request ceiling against runaway generation; the two span different scopes and neither has to sit below the other. Decrementing remaining is correct when your own code compacts or rewrites history between requests, because the server then has no memory of what was spent; with the full history resent, it under-reports the budget and ends tasks early. A per-request cap on its own is the whole answer when a task is one request. Low effort is the lever for depth per step, and the stem holds depth fixed.
Official Source: https://platform.claude.com/docs/en/build-with-claude/task-budgets ↗