Repository navigation
A turn may carry its own token cap (C6) - #118
Conversation
submit takes an optional budget_tokens for the turn it starts, checked before each model call where the bot's lifetime budget already is. A turn past it fails with turn_budget_exhausted and the facts turn_budget_tokens and turn_tokens_used. The cap is stored on the turn (migration 47 to 48), so a resumed turn counts what it spent, a resend naming another cap is an idempotency_conflict, and turns lists it. A steer with a cap is refused. run --turn-budget-tokens N passes it, and trigger add --turn-budget-tokens N makes every fire pass it. Protocol 11. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01L9TT37y1798majTjQbUtZW
|
You have reached your Codex usage limits for security reviews. Please try again later. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d315550d79
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
A keep-warm refresh during a long tool or reply bills the turn, so the refreshes now stop once they have billed what the bot's and turn's caps leave, and none start when the call itself reached a cap. A turn cap above i64::MAX is invalid_budget instead of wrapping in the store. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01L9TT37y1798majTjQbUtZW
|
@codex review Generated by Claude Code |
|
You have reached your Codex usage limits for security reviews. Please try again later. |
1 similar comment
|
You have reached your Codex usage limits for security reviews. Please try again later. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8602497e5d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Before: the only token cap was a bot's lifetime
--budget-tokens. A scheduled agent's one runaway fire could spend all of it.After:
submittakes an optionalbudget_tokensfor the turn it starts.run --turn-budget-tokens Nsends it, andtrigger add --turn-budget-tokens Nsends it on every fire. A turn that reaches its cap fails loudly withturn_budget_exhausted, just as a bot past its own budget fails withbudget_exhausted.This is C6 in the shipping plan, using the recommended pick for decision #15 (yes).
How
Bot::exhausted()names the bot's ownbudget_exhaustedfirst, since that cap outlasts the turn; otherwise it reportsturn_budget_exhaustedwith the factsturn_budget_tokensandturn_tokens_used.turns.budget_tokenscolumn, added by a one-way migration from schema 47 to 48.idempotency_conflict.turnslists each turn's cap.invalid_delivery, because it joins a turn that already has its own cap.invalid_budget, as it is forcreate.Defaults: no cap unless one is passed. The flag name
--turn-budget-tokenskeeps it apart from the creation setting--budget-tokens.Trigger runner: the app crate doesn't build on Linux. The trigger change was checked with
rustfmt --edition 2024and by reading it, and its unit tests (argument round trip,parse_add) were extended. The newtests/test_trigger.pycase runs only where the app builds, which is George's Mac.Performance: daemon CPU to finish 64 two-round tool turns, median of 15 runs on the synthetic model:
All three are within noise. The check is in memory, and the turn's spent count is read in the existing
context()row read. The migration is oneALTER TABLE ADD COLUMN, which changes only the schema and rewrites no rows.Tests:
-D warnings, fmt, the Python suite (433 tests, 55 skipped), and the node tests (207).schema_47_turns_take_their_own_token_cap(migration, the limit after a reload, facts, resend conflict, listing).test_a_turns_own_cap_stops_it_before_the_next_call(refusals, a tool still runs before the stop, the next turn starts from zero, a parked turn resumes, both caps at once).🤖 Generated with Claude Code