feat(core): add QuotaManager with exponential backoff and persistence#34
Open
iceteaSA wants to merge 1 commit into
Open
feat(core): add QuotaManager with exponential backoff and persistence#34iceteaSA wants to merge 1 commit into
iceteaSA wants to merge 1 commit into
Conversation
This was referenced May 21, 2026
Unified quota cache and API gateway for main + fallback quota state. All consumers share one QuotaManager instance for consistent caching. Features: - Inflight deduplication prevents concurrent API calls - Exponential backoff (60s-15min) for 429/5xx errors - Persists main quota and backoff state to disk via callbacks - Cross-process file lock guard for quota API dedup - Seeds from persisted storage on construction - Integrates with FallbackAccountManager for shared staleness - Captures storage path at init to prevent test config corruption - Request-count-based refresh trigger (refreshEveryNRequests)
There was a problem hiding this comment.
2 issues found across 6 files
Reply with feedback, questions, or to request a fix.
Fix all with cubic | Re-trigger cubic
3767882 to
731431a
Compare
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.
Unified quota cache and API gateway for main + fallback quota state. All consumers share one QuotaManager instance for consistent caching.
Features:
refreshEveryNRequests)Files:
packages/core/src/quota-manager.ts— new (391 lines)packages/core/src/accounts.ts— adds backoff helpers, FallbackAccountManager integrationpackages/opencode/src/index.ts— QuotaManager construction, persistence callbacks, routingpackages/opencode/src/tests/quota-manager.test.ts— new (294 lines)Summary by cubic
Adds a unified
QuotaManagerfor main and fallback quotas with shared in-memory cache, a serial API gate, exponential backoff, and on-disk persistence. Integrates it intopackages/opencodefor consistent routing, shared staleness with fallbacks, and safer behavior when rate-limited.New Features
QuotaManagerwith inflight dedup, a serialized API gate, and a cross‑process file lock.onMainQuotaFetched,onApiError).quota.refreshEveryNRequests.FallbackAccountManager: shared staleness checks, seeding from persisted fallback quotas, and gatedrefreshAllFallbacks.failClosedOnUnknownQuotareturns 429 withretry-after).Migration
@cortexkit/anthropic-auth-corenow exportsQuotaManager.FallbackAccountManager, pass a sharedQuotaManagerto unify cache and staleness across processes.QuotaManagercallbacks to savequota.mainQuota,quota.mainQuotaCheckedAt, andquota.mainLastQuotaApiError(already implemented inpackages/opencode).Written for commit 731431a. Summary will update on new commits. Review in cubic