Unify codex rotation retry guards

This commit is contained in:
ejclaw
2026-04-06 20:53:48 +09:00
parent 7612b2c4cc
commit fdc27836a3
5 changed files with 94 additions and 80 deletions

View File

@@ -1,11 +1,16 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
vi.mock('./agent-error-detection.js', () => ({
classifyRotationTrigger: vi.fn(() => ({
shouldRetry: false,
reason: '',
})),
}));
vi.mock('./agent-error-detection.js', async (importOriginal) => {
const actual =
await importOriginal<typeof import('./agent-error-detection.js')>();
return {
...actual,
classifyRotationTrigger: vi.fn(() => ({
shouldRetry: false,
reason: '',
})),
};
});
vi.mock('./codex-token-rotation.js', () => ({
detectCodexRotationTrigger: vi.fn(() => ({
@@ -71,6 +76,18 @@ describe('message-agent-executor-rules', () => {
).toEqual({ reason: 'auth-expired' });
});
it('ignores streamed reasons that are not valid Codex rotation triggers', () => {
expect(
resolveCodexRetryTrigger({
canRetryCodex: true,
attempt: {
streamedTriggerReason: { reason: 'usage-exhausted' },
},
}),
).toBeNull();
expect(detectCodexRotationTrigger).not.toHaveBeenCalled();
});
it('detects retryable Claude session failures from either flag or classifier', () => {
expect(
isRetryableClaudeSessionFailureAttempt({