Repository navigation
Part of #236: token budget and budget warning - #246
Merged
Merged
Conversation
This was referenced Oct 30, 2026
Merged
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.
Part of #236
Summary
Most of #236 was already on main:
--step-limit(turn cap),--cost-limitwith a per-model price table and price overrides, a warn-once message for unpriced models, and delegate cost counted against the parent. This slice adds what was missing:--token-limit n/ configtoken_limitcaps provider-reported input+output tokens for the whole run. At 100% the run stops cleanly with the new statusTokenLimitExceeded(exit 1, resumable; the printed--resumecommand doubles the limit).budget.warningevent (step, usage, tokens, token_limit, cost_usd, cost_limit) goes to the JSON stream, log DB and OTel trace.docs/runs.md(new "Token and cost budgets" section),docs/config.md,docs/long-runs.md,docs/subcommands.md; help text gets the new flag.How it was tested
New
internal/agent/budget_test.goandcmd/tinyagent/budget_test.go, all with fake models (no network or keys):TokenLimitExceededTokenLimitExceeded; a delegate isn't started when tokens are spent--token-limitflag override, negative-value validation, resume command doublingLocally:
gofmt -l .clean,go build ./...,go vet ./...,go test -count=1 ./...pass, plus cross-builds for windows/amd64, darwin/arm64, linux/arm64.Decisions on open questions