Repository navigation
Description
Problem
Evaluation callers such as SkillEvaluator need to bound total model usage across tasks, agents, repeats and retries. Per-call output limits, per-agent turn/time limits and dispatch walltime do not bound aggregate tokens or USD spent by a concurrent evaluation.
At Gym main 5678f14c, the collector has dispatch time limits, recovery tracks retry and walltime budgets, and repeat planning estimates an experiment before execution. I could not find a supported evaluation-wide token/USD admission budget.
Proposal
Add optional run-wide usage accounting and controls that stop starting additional work when the configured budget is exhausted. Define:
- Which agent, judge and auxiliary model calls count, including failed attempts and retries.
- Concurrent admission and accounting for work already running.
- USD pricing provenance and treatment of unknown or incomplete usage; missing measurements must not silently become zero.
- Persistence across resume, so restarting does not reset consumed budget.
- Whether the limit is an estimated admission limit or a strict enforcement guarantee, including treatment of in-flight work.
Keep evaluation-level admission in the evaluation control layer, coordinate measurement/enforcement with the model server, and reuse existing typed outcomes and stop/cleanup mechanisms where supported.
Acceptance criteria
- Unset budgets preserve current behavior; zero and invalid budgets have explicit behavior.
- Sequential and concurrent runs stop admitting work according to the documented policy.
- Accounting covers selected call categories, retries and in-flight reservations without double-counting.
- Resume preserves consumption and run identity.
- Reports retain completed results and distinguish budget exhaustion, not-started work and failures, including measurement gaps and pricing provenance.
- Integration coverage exercises concurrency, retries, missing usage, resume and cancellation.
Related work and duplicate check
- Implement benchmark and suite repeat-budget planning in Gym #6081 provides statistical repeat planning.
- Let callers stop a running rollout and still grade it #5091 / feat(agent): let a caller stop a running rollout and still grade it #5145 provide caller-driven stop-and-grade support.
- feat(episodes): enforce generation budgets across rollout retries #6453 and feat(agent): add standalone session turn budget proxy #4171 explored per-episode/session call limits and closed without merging. This aggregate evaluation request should incorporate the model-server ownership feedback on feat(episodes): enforce generation budgets across rollout retries #6453.
Searched open and closed issues and PRs for budget, max_cost, max_agent_tokens, spending, cost cap and token cap; no equivalent run-wide token/USD admission request found. This is a feature proposal based on source review, not an implemented or runtime-validated capability.
Activity
roy-tong commentedon Nov 21, 2026
Per-call limits do not compose. A run with two hundred calls each under the cap can still blow the aggregate budget by an order of magnitude. The useful primitive is a budget object owned by the run, checked before each call and settled after, so retries and nested tool calls count against the same ceiling. It also helps to expose remaining budget to the policy so it can degrade gracefully, shorter outputs or a cheaper model, instead of hard-failing at the end of a long eval, which is the most expensive possible outcome.
roy-tong commentedon Dec 1, 2026
The gap is that every existing budget is scoped to a call or an agent turn, while the thing you need to bound is the evaluation run. I'd add a run-scoped budget object with
max_total_tokens,max_total_usd,max_attempts, and areserve/commit/releaseprotocol: reserve before dispatch, commit on completion, release on failure. The check that matters is a concurrent run that exceeds the token budget mid-flight; it must stop dispatching new work, drain in-flight work, and report the partial result withbudget_exhaustedrather than silently truncating. Do you want the budget to include judge/eval model calls, or only the policy under test?