Format retry rule refactor files
This commit is contained in:
@@ -44,9 +44,7 @@ import {
|
|||||||
resolvePairedFollowUpQueueAction,
|
resolvePairedFollowUpQueueAction,
|
||||||
} from './message-agent-executor-rules.js';
|
} from './message-agent-executor-rules.js';
|
||||||
import { buildRoomRoleContext } from './room-role-context.js';
|
import { buildRoomRoleContext } from './room-role-context.js';
|
||||||
import {
|
import { type AgentTriggerReason } from './agent-error-detection.js';
|
||||||
type AgentTriggerReason,
|
|
||||||
} from './agent-error-detection.js';
|
|
||||||
import {
|
import {
|
||||||
runClaudeRotationLoop,
|
runClaudeRotationLoop,
|
||||||
runCodexRotationLoop,
|
runCodexRotationLoop,
|
||||||
@@ -759,9 +757,7 @@ export async function runAgentForGroup(
|
|||||||
const getPairedExecutionStatus = (): 'succeeded' | 'failed' =>
|
const getPairedExecutionStatus = (): 'succeeded' | 'failed' =>
|
||||||
pairedExecutionStatus;
|
pairedExecutionStatus;
|
||||||
|
|
||||||
const isRetryableClaudeSessionFailure = (
|
const isRetryableClaudeSessionFailure = (attempt: AgentAttempt): boolean =>
|
||||||
attempt: AgentAttempt,
|
|
||||||
): boolean =>
|
|
||||||
isRetryableClaudeSessionFailureAttempt({
|
isRetryableClaudeSessionFailureAttempt({
|
||||||
attempt,
|
attempt,
|
||||||
isClaudeCodeAgent,
|
isClaudeCodeAgent,
|
||||||
@@ -771,7 +767,10 @@ export async function runAgentForGroup(
|
|||||||
|
|
||||||
const recoverRetryableClaudeSessionFailure = async (
|
const recoverRetryableClaudeSessionFailure = async (
|
||||||
attempt: AgentAttempt,
|
attempt: AgentAttempt,
|
||||||
): Promise<{ attempt: AgentAttempt; resolved: 'success' | 'error' | null }> => {
|
): Promise<{
|
||||||
|
attempt: AgentAttempt;
|
||||||
|
resolved: 'success' | 'error' | null;
|
||||||
|
}> => {
|
||||||
if (!isRetryableClaudeSessionFailure(attempt)) {
|
if (!isRetryableClaudeSessionFailure(attempt)) {
|
||||||
return { attempt, resolved: null };
|
return { attempt, resolved: null };
|
||||||
}
|
}
|
||||||
@@ -916,7 +915,9 @@ export async function runAgentForGroup(
|
|||||||
// success-null-result with no visible output — agent returned nothing useful.
|
// success-null-result with no visible output — agent returned nothing useful.
|
||||||
// But if output was already delivered to Discord (sawOutput), treat as success.
|
// But if output was already delivered to Discord (sawOutput), treat as success.
|
||||||
if (attempt.sawSuccessNullResultWithoutOutput && !attempt.sawOutput) {
|
if (attempt.sawSuccessNullResultWithoutOutput && !attempt.sawOutput) {
|
||||||
log.error('Agent returned success with null result and no visible output');
|
log.error(
|
||||||
|
'Agent returned success with null result and no visible output',
|
||||||
|
);
|
||||||
return 'error';
|
return 'error';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -229,7 +229,9 @@ describe('runCodexRotationLoop', () => {
|
|||||||
|
|
||||||
it('continues rotation when streamed trigger arrives before visible output', async () => {
|
it('continues rotation when streamed trigger arrives before visible output', async () => {
|
||||||
vi.mocked(getCodexAccountCount).mockReturnValue(2);
|
vi.mocked(getCodexAccountCount).mockReturnValue(2);
|
||||||
vi.mocked(rotateCodexToken).mockReturnValueOnce(true).mockReturnValueOnce(false);
|
vi.mocked(rotateCodexToken)
|
||||||
|
.mockReturnValueOnce(true)
|
||||||
|
.mockReturnValueOnce(false);
|
||||||
|
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
const outcome = await runCodexRotationLoop(
|
const outcome = await runCodexRotationLoop(
|
||||||
|
|||||||
@@ -344,10 +344,7 @@ export async function runCodexRotationLoop(
|
|||||||
let trigger = initialTrigger;
|
let trigger = initialTrigger;
|
||||||
let lastRotationMessage = rotationMessage;
|
let lastRotationMessage = rotationMessage;
|
||||||
|
|
||||||
while (
|
while (getCodexAccountCount() > 1 && rotateCodexToken(lastRotationMessage)) {
|
||||||
getCodexAccountCount() > 1 &&
|
|
||||||
rotateCodexToken(lastRotationMessage)
|
|
||||||
) {
|
|
||||||
logger.info(
|
logger.info(
|
||||||
{ ...logContext, reason: trigger.reason },
|
{ ...logContext, reason: trigger.reason },
|
||||||
'Codex account unhealthy, retrying with rotated account',
|
'Codex account unhealthy, retrying with rotated account',
|
||||||
|
|||||||
Reference in New Issue
Block a user