Capacity as a Scheduling Input: Limits, Floors and Fallbacks
Paid AI tools have rolling usage limits. We made remaining capacity a first-class input to the scheduler, and learned what happens when every reviewer is unavailable at once.

Key Architectural Takeaways
- A collector reads each tool's own usage report and records nothing if it can't parse it.
- A weekly-window floor stopped the scheduler spending a tool that looked fine in its short window but was nearly out for the week.
- A stale 'not yet verified' gate once left 12 pull requests stalled with no available reviewer.
Limits are a fact of life
Each agent runs on a subscription with a short rolling window and a longer weekly one. There's no dependable remaining-balance API, so we read what each tool itself reports.
Collect, don't guess
A collector, built to run on a two-hour timer, asks each tool for its usage and writes the result to a ledger. It fails closed: a command error, an unparseable value, an out-of-range number or an already-rolled-over window records nothing, so an old report ages out instead of being replaced by a wrong number. One tool failing never blocks the others.
The weekly window is the real signal
One snapshot showed an agent with about 90% remaining in its short window but only about 42% for the week. Choosing it as usual would have burned the scarce resource. We added a conservative 50% floor for that agent's routine work, while keeping a 15% floor for the others. A person can still dispatch it explicitly.
Hit a limit? Route around it
When one tool hit its five-hour limit, the pipeline kept dispatching to it and each attempt became a failed job. Now the scheduler recognizes the limit message, parses the reset time (clamped to eight hours), benches that agent exactly until it resets, and only then brings in the metered fallback, and only while a primary tool is limited.
When everyone is out
On one night the Codex tool was limited, Gemini was at 0%, and the metered fallback was benched after two cost spikes. Grok was available and had a proven dispatch record, but a stale 'not yet live-verified' gate kept it out of the enabled list. The pipeline reported no available reviewer and 12 pull requests stalled. The fix enabled Grok as the last primary reviewer, after the others.
Takeaway
Treat capacity like any other dependency: measure it, fail closed on bad data, and re-check the gates you put in place early on. Temporary guards become outages when nobody revisits them.