feat: automated quota steering + sonnet repin for execution agents#121
Merged
Conversation
Statusline persists rate_limits to ~/.claude/tmp/rate-limits.json on every refresh and shows a weekly wk% badge at >=50%. New quota-steer UserPromptSubmit hook reads the cache, computes a band (elevated at 60% 5h / 65% weekly, critical at 85%), and injects routing guidance: bulk work to Codex when the bridge is available, sonnet downshift when not. Emits on band upgrade only, re-reminds every 30min at critical, fails open on missing/stale cache.
…uting Execution and diff-reading move to the roomy Sonnet 5 pool; planner, maestro, and security-reviewer stay top-tier for gate decisions. Docs updated for the automated steering mechanism and the Fable promo window status.
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.
What this does
Claude Code only exposes your real usage numbers to the statusline — nothing else can see them, so all the "route by headroom" guidance in our docs was advisory prose the model could ignore. This PR makes it enforced: sessions now get an automatic in-context nudge to route bulk work to Codex (or downshift to Sonnet) the moment usage actually gets high, and the two biggest token-consuming agents move off the scarce Opus pool.
Summary
statusline.tspersistsrate_limits(5-hour + weekly) to~/.claude/tmp/rate-limits.jsonon every refresh, and renders the previously-ignored weekly percentage as awk%badge at ≥50%src/lib/quota.ts— pure band logic (elevated at 60% 5h / 65% weekly, critical at 85%) with unit testssrc/hooks/quota-steer.ts(UserPromptSubmit) — injects routing guidance on band upgrade, re-reminds every 30 min at critical, resets on return to normal; reads the cached Codex verdict to pick between "batch into Codex" and "downshift to sonnet"; fail-open on missing/stale (>10 min) cacheimplementeropus→sonnet,revieweropus[1m]→sonnet;planner/maestro/security-reviewerstay top-tier (gate decisions)scripts-smoke.test.tscheckpoint fixture hardened: fails loudly and disables gpg signing/hooks so it survives machines with globalcommit.gpgsign=trueTest Plan
bun test— 767 pass, 0 fail (includes newtests/quota.test.ts)bun run typecheck,bun run lint,bun run lint:skillscleanunknownsetup.shso the hooks fingerprint covers the newquota-steerregistration