Format retry transition refactor files
This commit is contained in:
@@ -1410,9 +1410,8 @@ describe('runAgentForGroup room memory', () => {
|
|||||||
expect(
|
expect(
|
||||||
vi.mocked(db.insertPairedTurnOutput).mock.invocationCallOrder[0],
|
vi.mocked(db.insertPairedTurnOutput).mock.invocationCallOrder[0],
|
||||||
).toBeLessThan(
|
).toBeLessThan(
|
||||||
vi.mocked(
|
vi.mocked(pairedExecutionContext.completePairedExecutionContext).mock
|
||||||
pairedExecutionContext.completePairedExecutionContext,
|
.invocationCallOrder[0],
|
||||||
).mock.invocationCallOrder[0],
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -34,9 +34,7 @@ import {
|
|||||||
} from './paired-execution-context.js';
|
} from './paired-execution-context.js';
|
||||||
import { resolveCodexFallbackHandoff } from './paired-turn-fallback.js';
|
import { resolveCodexFallbackHandoff } from './paired-turn-fallback.js';
|
||||||
import { resolveExecutionTarget } from './message-runtime-rules.js';
|
import { resolveExecutionTarget } from './message-runtime-rules.js';
|
||||||
import {
|
import { resolvePairedFollowUpQueueAction } from './message-agent-executor-rules.js';
|
||||||
resolvePairedFollowUpQueueAction,
|
|
||||||
} from './message-agent-executor-rules.js';
|
|
||||||
import { buildRoomRoleContext } from './room-role-context.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 {
|
import {
|
||||||
|
|||||||
@@ -851,7 +851,10 @@ export function createMessageRuntime(deps: MessageRuntimeDeps): {
|
|||||||
chatJid,
|
chatJid,
|
||||||
getRecentChatMessages(chatJid, 20),
|
getRecentChatMessages(chatJid, 20),
|
||||||
),
|
),
|
||||||
lastDeliveredMessages: labelPairedSenders(chatJid, missedMessages),
|
lastDeliveredMessages: labelPairedSenders(
|
||||||
|
chatJid,
|
||||||
|
missedMessages,
|
||||||
|
),
|
||||||
resolveChannel,
|
resolveChannel,
|
||||||
})
|
})
|
||||||
: null;
|
: null;
|
||||||
|
|||||||
@@ -141,10 +141,7 @@ export function transitionPairedTaskStatus(args: {
|
|||||||
currentStatus: PairedTaskStatus;
|
currentStatus: PairedTaskStatus;
|
||||||
nextStatus: PairedTaskStatus;
|
nextStatus: PairedTaskStatus;
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
patch?: Omit<
|
patch?: Omit<Parameters<typeof updatePairedTask>[1], 'status' | 'updated_at'>;
|
||||||
Parameters<typeof updatePairedTask>[1],
|
|
||||||
'status' | 'updated_at'
|
|
||||||
>;
|
|
||||||
}): void {
|
}): void {
|
||||||
assertPairedTaskStatusTransition({
|
assertPairedTaskStatusTransition({
|
||||||
currentStatus: args.currentStatus,
|
currentStatus: args.currentStatus,
|
||||||
|
|||||||
@@ -512,34 +512,34 @@ async function runTask(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const provider = context.taskAgentType === 'codex' ? 'codex' : 'claude';
|
const provider = context.taskAgentType === 'codex' ? 'codex' : 'claude';
|
||||||
|
|
||||||
{
|
{
|
||||||
const attempt = await runTaskAttempt(provider);
|
const attempt = await runTaskAttempt(provider);
|
||||||
result = attempt.attemptResult;
|
result = attempt.attemptResult;
|
||||||
error = attempt.attemptError;
|
error = attempt.attemptError;
|
||||||
|
|
||||||
const retryAction = resolveAttemptRetryAction({
|
const retryAction = resolveAttemptRetryAction({
|
||||||
provider,
|
provider,
|
||||||
canRetryClaudeCredentials: provider === 'claude' && getTokenCount() > 0,
|
canRetryClaudeCredentials: provider === 'claude' && getTokenCount() > 0,
|
||||||
canRetryCodex: provider === 'codex' && getCodexAccountCount() > 1,
|
canRetryCodex: provider === 'codex' && getCodexAccountCount() > 1,
|
||||||
attempt,
|
attempt,
|
||||||
rotationMessage: error,
|
rotationMessage: error,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (retryAction.kind === 'claude') {
|
if (retryAction.kind === 'claude') {
|
||||||
await retryClaudeTaskWithRotation(
|
await retryClaudeTaskWithRotation(
|
||||||
retryAction.trigger,
|
retryAction.trigger,
|
||||||
retryAction.rotationMessage,
|
retryAction.rotationMessage,
|
||||||
);
|
);
|
||||||
} else if (retryAction.kind === 'codex') {
|
} else if (retryAction.kind === 'codex') {
|
||||||
await retryCodexTaskWithRotation(
|
await retryCodexTaskWithRotation(
|
||||||
retryAction.trigger,
|
retryAction.trigger,
|
||||||
retryAction.rotationMessage,
|
retryAction.rotationMessage,
|
||||||
);
|
);
|
||||||
} else if (attempt.output.status === 'error') {
|
} else if (attempt.output.status === 'error') {
|
||||||
error = attempt.attemptError || 'Unknown error';
|
error = attempt.attemptError || 'Unknown error';
|
||||||
}
|
}
|
||||||
} // end else (non-exhausted path)
|
} // end else (non-exhausted path)
|
||||||
|
|
||||||
log.info(
|
log.info(
|
||||||
|
|||||||
Reference in New Issue
Block a user