feat(workflows): token + cost budgets across the run tree (B3, #2212) - #2528
Merged
Conversation
…ts/token-cost-budget # Conflicts: # packages/workflows/CHANGELOG.md
Declare finalDecision, scoreTablePath, and reviewReportPath without placeholder values that GitHub Code Quality flagged as dead stores. Every loop path assigns them before return. Assistant-model: Grok 4.6
flora131
marked this pull request as ready for review
August 19, 2026 16:53
|
|
||
| ## [Unreleased] | ||
|
|
||
| ### Added |
There was a problem hiding this comment.
Duplicate changelog and ambiguous types
This creates a second ### Added subsection instead of appending to the existing Unreleased subsection; the same change also introduces ambiguous unknown typing in dbos-envelope.ts and budget-meter.ts, splitting release notes and weakening compile-time shape checking for usage accounting.
Context Used: AGENTS.md (source)
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/workflows/CHANGELOG.md
Line: 9
Comment:
**Duplicate changelog and ambiguous types**
This creates a second `### Added` subsection instead of appending to the existing Unreleased subsection; the same change also introduces ambiguous `unknown` typing in `dbos-envelope.ts` and `budget-meter.ts`, splitting release notes and weakening compile-time shape checking for usage accounting.
**Context Used:** AGENTS.md ([source](https://github.com/bastani-inc/atomic/blob/main/AGENTS.md))
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
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
Slice B3 of the run-budgets track (
specs/2026-08-17-run-budgets.md§5.1meter_run+ §8 B3): token + cost budgets across the whole run tree.meter_run(tree, now)→RunMeters {durationMs, tokens, cost, perCounter{input,output,cacheRead,cacheWrite}}usage.input+usage.output) — Codexgoal_token_delta_for_usage; cache reads/writes reported, never charged tomaxTokens(maxCostowns cache-heavy spend)usage.costfold_usage(V6) including nestedctx.workflowchildren and retries (R4)This branch first merges
origin/verifier/cost-ledger(fold_usage) into B2. Base:budgets/duration-enforcement(B2, #2527). Completes Stack B and issue #2212.Evidence
Produced by an implement→review→repair goal run (5 turns; completion/evidence
complete; riskcontinue;remaining_work: none; approved):npm run check— green (includes the coding-agent tsgoerasableSyntaxOnlypass)npx vitest --run --project unit -t "budget"— green: input+output-only token charge with all four counters reported; cost summation; delta monotonicity; single-accountant; independent concurrent runs; resume carries baselinespackages/workflows/CHANGELOG.mdunder## [Unreleased]### AddedSpec contract:
specs/2026-08-17-run-budgets.md§5.1 / §8 B3.Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Greptile Summary
This change adds token and cost limits to workflow run budgets, carrying accounting across nested workflows, retries, checkpoints, and durable resumes. It also adds budget warnings, status reporting, and documentation for the new limits.
The workflow changelog needs consolidation: Unreleased additions are split across duplicate
### Addedsections, and the related usage-accounting changes retain ambiguousunknowntyping.Confidence Score: 4/5
The implementation adds substantial budget-accounting behavior; the remaining issue is limited to repository-required changelog and type-quality cleanup.
There is one non-security P2 finding, so the score is 4 under the required scoring table.
Files Needing Attention: packages/workflows/CHANGELOG.md, plus the usage-accounting type declarations in dbos-envelope.ts and budget-meter.ts.
Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "merge origin/main" | Re-trigger Greptile
Context used: