Conversation
…uto-save Adds a friendly UX layer on top of the existing quota.py engine so users can cap spend per session or per day, in tokens or USD, and never lose work when a cap is hit. - /budget command (commands/core.py): view usage vs each cap as colored bars + %, or set one — /budget $5 (cost), /budget 200k (tokens, parses 200k/1.5m), /budget daily $20, /budget clear. --budget $5 / --budget 200k startup flag. - One budget per scope: a new cap REPLACES the other unit for that scope, so switching tokens<->USD just works and no stale cap silently keeps blocking. - Tight enforcement (no surprise overshoot): check_quota projects the next request's input and stops BEFORE the call if it would cross the cap; quota.output_room clamps that call's max_tokens to the remaining headroom — a tool-heavy turn can't blow 40k->49k past the budget anymore. - Proximity warnings at >=80% (yellow) / >=95% (red) end-of-turn. - On hit: agent yields QuotaPause (carrying which cap broke: key/scope/unit/ limit); the REPL auto-saves the session (session_latest.json + daily backup, the path /resume reads) and prints next steps. The "raise it" hint matches the breached unit (token cap -> /budget 40k, daily cost -> /budget daily $40). quota.py: parse_budget / fmt_amount / usage_vs_limits / warnings / output_room, projected check_quota, QuotaExceeded carries the breached cap. agent.py: QuotaPause + projection + output clamp. cheetahclaws.py: /budget registration, QuotaPause handling, --budget, near-limit warnings. 42-case tests/test_budget.py (isolated quota dir). Docs: README, features.md, reference.md, news.md. Defaults stay unlimited (interactive); daemon serve-mode guardrails unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.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.
…uto-save
Adds a friendly UX layer on top of the existing quota.py engine so users can cap spend per session or per day, in tokens or USD, and never lose work when a cap is hit.
quota.py: parse_budget / fmt_amount / usage_vs_limits / warnings / output_room, projected check_quota, QuotaExceeded carries the breached cap. agent.py: QuotaPause + projection + output clamp. cheetahclaws.py: /budget registration, QuotaPause handling, --budget, near-limit warnings. 42-case tests/test_budget.py (isolated quota dir). Docs: README, features.md, reference.md, news.md. Defaults stay unlimited (interactive); daemon serve-mode guardrails unchanged.