fix(tui): harden usage heartbeat and auth-profile auto-switch#180
Closed
andrei-hasna wants to merge 1 commit into
Closed
fix(tui): harden usage heartbeat and auth-profile auto-switch#180andrei-hasna wants to merge 1 commit into
andrei-hasna wants to merge 1 commit into
Conversation
…smarter Under rate limits the auth-profile usage heartbeat kept re-polling an already-exhausted profile every interval once its cached snapshot lapsed freshness, hammering the usage endpoint until reset (the Jul-7 reset incidents). Auto-switch could also optimistically pick an Unknown or just-failed profile over a known-healthy one. - Track the earliest future reset for a profile whose cached codex usage is exhausted and suppress heartbeats for it until that reset, falling back to the normal interval/backoff when the reset is missing or has elapsed so heartbeats are never permanently blocked. - Ordered auto-switch now returns the first healthy profile in configured order and only defers to an Unknown profile when nothing is known healthy, instead of grabbing the first Unknown it sees. - Skip auto-switching onto a profile whose most recent usage heartbeat failed within the failure backoff. Adds core + TUI tests; preserves config defaults and TOML back-compat. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
Author
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.
Summary
Improves the auth-profile usage heartbeat and auto-switch so profile selection is smarter and usage endpoints are not hammered under rate limits (the recurring Jul-7 reset incidents where a health loop kept hitting
Codewith usage limit hit).Do not hammer usage endpoints under rate limits
used_percent >= 100), and suppress usage heartbeats for that profile until the reset. Nothing changes until reset, so re-polling everyheartbeat_intervaljust hammered a limit we already knew about.Smarter auto-switch profile selection
Orderedstrategy now returns the first healthy profile in configured order and only defers to anUnknownprofile when nothing is known-healthy, instead of optimistically grabbing the firstUnknown.Tests / validation (in
codex-rs/)cargo test -p codex-core usage_profile_health— 18 passed (new:earliest_exhausted_reset_at, ordered healthy-before-unknown)cargo test -p codex-tuichatwidget popups/status modules — 251 passed (new:usage_heartbeat_suppressed_for_exhausted_profile_until_reset,auto_switch_skips_recently_failed_profile_for_unknown_candidate)cargo clippy -p codex-core -p codex-tui --all-targets— cleancargo fmt --check— cleanPreserves config defaults and TOML back-compat; no behavior change when auto-switch is disabled.
🤖 Generated with Claude Code