@@ -215,7 +215,8 @@ export class EmbeddingQuotaExhaustedError extends EmbeddingAPIError {
215215 /**
216216 * `isBYOK` must be passed when there is no provider response to read it from — an
217217 * already-open quota pause or an admission refusal — so a workspace key's exhaustion
218- * is never reported as the platform's.
218+ * is never reported as the platform's. Ollama takes no credential: its provider-level
219+ * `isBYOK` only marks its tokens non-billable, so it never attributes to a customer key.
219220 */
220221 constructor (
221222 providerId : EmbeddingProviderKind ,
@@ -226,7 +227,7 @@ export class EmbeddingQuotaExhaustedError extends EmbeddingAPIError {
226227 super (
227228 `The ${ providerId } embedding credential has exhausted its available quota. Add credit or replace the credential before retrying.` ,
228229 status ,
229- isBYOK
230+ isBYOK && providerId !== 'ollama'
230231 )
231232 this . name = 'EmbeddingQuotaExhaustedError'
232233 this . providerId = providerId
@@ -249,8 +250,15 @@ export function isEmbeddingQuotaExhaustion(error: unknown): boolean {
249250 return false
250251}
251252
252- /** True when a customer-managed embedding credential has no remaining credit. */
253- export function isBYOKEmbeddingQuotaExhaustion ( error : unknown ) : error is EmbeddingAPIError {
253+ /**
254+ * True when the operation failed on quota and a customer-managed credential is among
255+ * the exhausted ones: adding credit to that key is what lets it run again, even when a
256+ * platform fallback behind it is exhausted too.
257+ */
258+ export function isBYOKEmbeddingQuotaExhaustion ( error : unknown ) : boolean {
259+ if ( error instanceof AggregateError ) {
260+ return isEmbeddingQuotaExhaustion ( error ) && error . errors . some ( isBYOKEmbeddingQuotaExhaustion )
261+ }
254262 return error instanceof EmbeddingAPIError && error . isBYOK && error . quotaExhausted === true
255263}
256264
0 commit comments