feat: quota tracking and load rotation across subscriptions - #7
Conversation
|
Extended with live usage probes — the selector now asks vendors for remaining quota before launching, falling back to cooldowns wherever the probe can't answer. Live-validated on this machine: |
Engine runs record outcomes in local state; a run that hits a usage limit puts the engine on cooldown (vendor retry-after hints parsed, cooldownMinutes fallback) and it is skipped until expiry. maxEngines / --max-engines runs the n least-recently-used healthy engines per review, rotating load across subscriptions. New usage command; doctor shows cooldowns; action caches the state dir across CI runs and now auto-detects glm/qwen from ZAI_API_KEY/QWEN_API_KEY. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CQy3ZJ5MyUxo4qjZwA93Na
Optional usageProbe per engine, consulted before selection; a probed engine at 0% never launches, and probe failure of any kind falls back to the reactive cooldowns. Claude reads its own login token (file or macOS Keychain) against the OAuth usage API; glm hits Z.ai's monitor endpoint with the inference key; kimi uses its documented coding usage endpoint; qwen needs a pasted console session cookie since Alibaba gates usage data behind console auth. Codex and grok have no vendor endpoint for subscription limits and stay on cooldowns. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CQy3ZJ5MyUxo4qjZwA93Na
c3b21b0 to
0262d4a
Compare
Never launch an engine that's out of quota, and spread load across the subs that still have headroom:
~/.local/state/kyora-review/usage.json. A run that hits a usage limit (detected from vendor error signatures on failed runs only — a finding about rate limiting can't false-positive) puts that engine on cooldown: vendor "try again in N hours/minutes" hints are parsed when present, otherwisecooldownMinutes(default 60). Cooled-down engines are skipped with a log line;--ignore-quotaforces them; if the whole panel is cooling, the run no-ops CI-safe instead of burning attempts.--max-engines <n>/maxEnginesconfig runs only the n least-recently-used healthy engines per review — with a 6-engine panel andmax-engines: 3, consecutive PRs rotate through different subscription triples.kyora-review usageshows per-engine runs, last outcome, and remaining cooldown;doctorannotates cooldowns inline.~/.codex, so cooldowns survive between workflow runs. Also fixes the action's auto-detection gap for the new engines:ZAI_API_KEY→ glm,QWEN_API_KEY→ qwen (and claude-binary install covers both); dropped the dead qwen-code install.Stacked on #6 — merge that first and this collapses to the quota changes.
🤖 Generated with Claude Code
https://claude.ai/code/session_01CQy3ZJ5MyUxo4qjZwA93Na