@@ -79,10 +79,7 @@ const EMBEDDING_RETRY_BUDGET_MS = EMBEDDING_MAX_RETRIES * EMBEDDING_MAX_RETRY_DE
7979export class EmbeddingAPIError extends Error {
8080 public status : number
8181
82- /**
83- * The provider rejected this for an exhausted balance rather than a rate that
84- * will recover. Both arrive as 429.
85- */
82+ /** Rejected for an exhausted balance rather than a recoverable rate. Both are 429. */
8683 public quotaExhausted ?: boolean
8784
8885 /**
@@ -100,13 +97,8 @@ export class EmbeddingAPIError extends Error {
10097
10198/**
10299 * True when a rejection body reports an exhausted balance rather than a rate
103- * limit.
104- *
105- * OpenAI returns 429 for both, but only one of them reopens. `insufficient_quota`
106- * stands until somebody adds credit, so retrying it cannot succeed no matter how
107- * long the loop waits — and because a failed document is re-queued by the sweep
108- * on every sync, an account that has run out turns into a permanent load: the
109- * budget is spent per document, per attempt, forever.
100+ * limit. OpenAI returns 429 for both, but only a rate limit reopens: a spent
101+ * account stands until someone adds credit, so retrying it cannot succeed.
110102 */
111103function isQuotaExhaustionBody ( errorText : string ) : boolean {
112104 try {
@@ -148,13 +140,10 @@ function statedWaitOutlastsBudget(error: unknown): boolean {
148140}
149141
150142/**
151- * Whether another attempt against the same provider could plausibly succeed.
152- *
153- * Deliberately narrower than {@link isTransientEmbeddingError}, which also
154- * decides whether the fallback chain should try a *different* provider. Those
155- * two questions differ: an exhausted balance rules out the key we just used, but
156- * says nothing about the next one in the chain, so a quota rejection stops the
157- * retries here while remaining eligible for failover.
143+ * Whether another attempt against the *same* provider could succeed. Narrower
144+ * than {@link isTransientEmbeddingError}, which decides whether to fail over to a
145+ * different one: an exhausted balance rules out the key just used but says
146+ * nothing about the next in the chain.
158147 */
159148function isWorthRetrying ( error : unknown ) : boolean {
160149 if ( ! isTransientEmbeddingError ( error ) ) return false
0 commit comments