Skip to content

Fix weekly quota window exhaustion detection and candidate ranking - #6

Closed
klepsydra wants to merge 1 commit into
zcop:mainfrom
klepsydra:fix-auto-mode-quota-exhaustion
Closed

klepsydra wants to merge 1 commit into
zcop:mainfrom
klepsydra:fix-auto-mode-quota-exhaustion

Conversation

@klepsydra

@klepsydra klepsydra commented Sep 29, 2026 •

Copy link
Copy Markdown

Problem

  1. When Cloud Code quota summary only returns gemini-weekly (window: weekly) without a 5h rolling window (window: 5h), usage_windows["short"] remains status: "unknown".
  2. _is_short_window_exhausted() previously only inspected the short window. Because short was unknown, ensure_active_account() never triggered failover even if the weekly quota was exhausted (0.0% remaining).
  3. _best_switch_candidate() did not penalize accounts with exhausted weekly quota, potentially picking exhausted accounts during automatic candidate ranking.

Solution

  • Updated _is_short_window_exhausted() to check both short and weekly quota windows for usage <= threshold.
  • Updated _cooldown_minutes_from_short_window() to compute cooldown from the reset timestamp of the exhausted window (short or weekly).
  • Updated candidate ranking in _best_switch_candidate() to penalize accounts with low/exhausted weekly quota, prioritizing accounts with available quota.
  • Added regression test test_weekly_window_exhaustion_triggers_failover to tests/test_manager_regressions.py.

@klepsydra

Copy link
Copy Markdown
Author

In my fork https://github.com/klepsydra/agy-cli-manager , I don't want you to invent agy-cli-manager auto subcommand, when actually i mistyped "agy-cli-manager switch-mode
auto" here in agy prompts. Make sure that's reflected in Pull Request: zcop/agy-cli-manager #6 #6

@klepsydra
klepsydra marked this pull request as draft September 29, 2026 20:46
- Update _is_short_window_exhausted and _cooldown_minutes_from_short_window to evaluate both short (5h) and weekly quota windows
- Update candidate ranking so low/exhausted weekly quota accounts are deprioritized below accounts with available quota
- Add regression test for weekly window quota exhaustion failover
@klepsydra
klepsydra force-pushed the fix-auto-mode-quota-exhaustion branch from 47d8309 to 58fb380 Compare September 30, 2026 00:03
@klepsydra klepsydra changed the title Fix weekly quota window exhaustion detection and add auto command Fix weekly quota window exhaustion detection and candidate ranking Sep 30, 2026
@klepsydra
klepsydra changed the base branch from master to main September 30, 2026 00:03
@zcop

zcop commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Reviewed by Codex

Thank you for identifying the weekly quota exhaustion gap. This is now implemented on main in commit 2fa9951.

The merged implementation covers the same weekly-window detection and extends it to the current family-aware quota model:

  • evaluates both five-hour and weekly windows for Gemini and Other (Claude/GPT) families
  • uses the configured per-family threshold
  • derives cooldown from the latest blocking reset
  • rejects candidates already depleted for the requested family
  • keeps quota cooldown scoped to the affected family
  • includes deterministic regression coverage

Because PR #6 is now superseded by the implementation on main and conflicts with the updated code, it no longer needs to be merged. Thanks again for reporting the issue and proposing the fix.

@zcop

zcop commented Oct 1, 2026

Copy link
Copy Markdown
Owner

Closing as superseded by 2fa9951 on main.

@zcop zcop closed this Oct 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants