Format retry rule refactor files

This commit is contained in:
ejclaw
2026-04-06 20:38:38 +09:00
parent 83c45c3ce3
commit 7612b2c4cc
3 changed files with 13 additions and 13 deletions

View File

@@ -44,9 +44,7 @@ import {
resolvePairedFollowUpQueueAction,
} from './message-agent-executor-rules.js';
import { buildRoomRoleContext } from './room-role-context.js';
import {
type AgentTriggerReason,
} from './agent-error-detection.js';
import { type AgentTriggerReason } from './agent-error-detection.js';
import {
runClaudeRotationLoop,
runCodexRotationLoop,
@@ -759,9 +757,7 @@ export async function runAgentForGroup(
const getPairedExecutionStatus = (): 'succeeded' | 'failed' =>
pairedExecutionStatus;
const isRetryableClaudeSessionFailure = (
attempt: AgentAttempt,
): boolean =>
const isRetryableClaudeSessionFailure = (attempt: AgentAttempt): boolean =>
isRetryableClaudeSessionFailureAttempt({
attempt,
isClaudeCodeAgent,
@@ -771,7 +767,10 @@ export async function runAgentForGroup(
const recoverRetryableClaudeSessionFailure = async (
attempt: AgentAttempt,
): Promise<{ attempt: AgentAttempt; resolved: 'success' | 'error' | null }> => {
): Promise<{
attempt: AgentAttempt;
resolved: 'success' | 'error' | null;
}> => {
if (!isRetryableClaudeSessionFailure(attempt)) {
return { attempt, resolved: null };
}
@@ -916,7 +915,9 @@ export async function runAgentForGroup(
// success-null-result with no visible output — agent returned nothing useful.
// But if output was already delivered to Discord (sawOutput), treat as success.
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';
}

View File

@@ -229,7 +229,9 @@ describe('runCodexRotationLoop', () => {
it('continues rotation when streamed trigger arrives before visible output', async () => {
vi.mocked(getCodexAccountCount).mockReturnValue(2);
vi.mocked(rotateCodexToken).mockReturnValueOnce(true).mockReturnValueOnce(false);
vi.mocked(rotateCodexToken)
.mockReturnValueOnce(true)
.mockReturnValueOnce(false);
let attempts = 0;
const outcome = await runCodexRotationLoop(

View File

@@ -344,10 +344,7 @@ export async function runCodexRotationLoop(
let trigger = initialTrigger;
let lastRotationMessage = rotationMessage;
while (
getCodexAccountCount() > 1 &&
rotateCodexToken(lastRotationMessage)
) {
while (getCodexAccountCount() > 1 && rotateCodexToken(lastRotationMessage)) {
logger.info(
{ ...logContext, reason: trigger.reason },
'Codex account unhealthy, retrying with rotated account',