Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,15 @@ describe('Provider error classification', () => {
data: { error: { code: 'insufficient_quota' } },
});
assert.equal(classifyError(quotaOn401), 'ProviderBilling');
assert.equal(providerFailureDiagnostic(quotaOn401).errorClass, 'ProviderBilling');

const balanceOn403 = Object.assign(new Error('request failed'), {
name: 'AI_APICallError',
statusCode: 403,
data: { error: { code: 'insufficient_balance' } },
});
assert.equal(classifyError(balanceOn403), 'ProviderBilling');
assert.equal(providerFailureDiagnostic(balanceOn403).errorClass, 'ProviderBilling');

// Explicit provider evidence outranks the numeric HTTP fallback: an
// exhausted quota is a closed window, not a transient throttle to retry.
Expand All @@ -86,6 +88,7 @@ describe('Provider error classification', () => {
});
assert.equal(classifyError(quotaOn429), 'ProviderBilling');
assert.equal(providerRetryMetadata(quotaOn429).retryable, false);
assert.equal(providerFailureDiagnostic(quotaOn429).errorClass, 'ProviderBilling');
});

test('plan-window wording on a credential-shaped status projects to billing', () => {
Expand All @@ -100,6 +103,7 @@ describe('Provider error classification', () => {
});
assert.equal(classifyError(planWindow), 'ProviderBilling');
assert.equal(providerRetryMetadata(planWindow).retryable, false);
assert.equal(providerFailureDiagnostic(planWindow).errorClass, 'ProviderBilling');

const exhaustedCredits = Object.assign(new Error('Request failed with status code 403'), {
name: 'AI_APICallError',
Expand All @@ -109,6 +113,7 @@ describe('Provider error classification', () => {
}),
});
assert.equal(classifyError(exhaustedCredits), 'ProviderBilling');
assert.equal(providerFailureDiagnostic(exhaustedCredits).errorClass, 'ProviderBilling');
});

test('genuine credential and permission failures stay auth on 401/403', () => {
Expand Down
1 change: 1 addition & 0 deletions packages/runtime/src/provider-error-classification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,7 @@ function durableProviderErrorClass(
if (
classified === 'ContextLength' ||
classified === 'ProviderCapacity' ||
classified === 'ProviderBilling' ||
(classified === 'ProviderUnavailable' && isTrustedCodexEdgeRejection(facts))
) {
return classified;
Expand Down