feat(cli): add --budget-usd run-level cost cap#1118
Merged
Conversation
Add a `--budget-usd` flag to `agentv run` that caps total cost across all eval files in a single invocation. When the cumulative cost exceeds the cap, remaining eval files are skipped with `budget_exceeded` results. Implementation: - New `RunBudgetTracker` class in packages/core for reusable budget tracking - CLI flag with validation (must be positive number) - Integrated into sequential file loop: costs accumulated after each file, budget checked before dispatching the next file - Per-suite `execution.budget_usd` still enforced within files by orchestrator - Exit code 1 when run-level budget is exceeded - Summary output shows cap and actual spend when exceeded Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a
--budget-usd <n>flag to therunsubcommand that caps total cost across all eval files in one invocation.Closes #1113
Changes
RunBudgetTracker(packages/core/src/evaluation/run-budget-tracker.ts): New class tracking cumulative cost withadd(),isExceeded(),currentCostUsd,budgetCapUsdrun.ts): Added--budget-usdoption with validation (rejects ≤ 0)run-eval.ts: AddedbudgetUsdtoNormalizedOptionsandRunEvalResult, integrated tracker into sequential file loop — accumulates costs after each file, skips remaining files withbudget_exceededresultsRunBudgetTrackerRunBudgetTrackerexported from@agentv/coreE2E Verification
Red (validation rejects invalid values):
Green (flag appears in help):
Test Results
472/472 pass, 0 failures