fix: suppress Claude 502 provider errors from chat output

This commit is contained in:
Eyejoker
2026-03-26 10:11:24 +09:00
parent bba19b0c0f
commit a330ebdf2a
7 changed files with 239 additions and 2 deletions

View File

@@ -1,7 +1,9 @@
import { describe, expect, it } from 'vitest';
import {
classifyAgentError,
classifyClaudeAuthError,
detectClaudeProviderFailureMessage,
isClaudeOrgAccessDeniedMessage,
isNoFallbackCooldownReason,
shouldRotateClaudeToken,
@@ -38,6 +40,22 @@ describe('agent-error-detection', () => {
});
});
it('classifies Cloudflare 502 HTML as overloaded', () => {
const message = `API Error: 502 <html>
<head><title>502 Bad Gateway</title></head>
<body>
<center><h1>502 Bad Gateway</h1></center>
<hr><center>cloudflare</center>
</body>
</html>`;
expect(classifyAgentError(message)).toEqual({
category: 'overloaded',
reason: 'overloaded',
});
expect(detectClaudeProviderFailureMessage(message)).toBe('overloaded');
});
it('marks only Claude quota/auth reasons as Claude rotation reasons', () => {
expect(shouldRotateClaudeToken('429')).toBe(true);
expect(shouldRotateClaudeToken('usage-exhausted')).toBe(true);