fix: stop Codex pool retry loops

This commit is contained in:
ejclaw
2026-06-02 05:29:32 +09:00
parent 03d4c81192
commit 5648b61075
16 changed files with 369 additions and 24 deletions

View File

@@ -12,8 +12,10 @@ import { ASSISTANT_NAME, SCHEDULER_POLL_INTERVAL, TIMEZONE } from './config.js';
import { AgentOutput, runAgentProcess } from './agent-runner.js';
import {
getAllTasks,
getAllOpenPairedTasks,
deleteTask,
getDueTasks,
hasActiveCiWatcherForChat,
getTaskById,
logTaskRun,
updateTask,
@@ -44,6 +46,8 @@ import {
} from './task-suspension.js';
import { getTaskQueueJid, isGitHubCiTask } from './task-watch-status.js';
import { ScheduledTask } from './types.js';
import { resolveGroupIpcPath } from './group-folder.js';
import { schedulePairedFollowUpOnce } from './paired-follow-up-scheduler.js';
import {
hasTaskExceededMaxDuration,
resolveTaskExecutionContext,
@@ -506,6 +510,7 @@ export async function runSchedulerTickOnce(
): Promise<void> {
// Unified service: process all agent types, not just the service default.
const nowMs = Date.now();
reconcileOrphanedPairedReviewReadyTasks(deps);
const activeTasks = getAllTasks().filter((task) => task.status === 'active');
for (const task of activeTasks) {
@@ -550,6 +555,45 @@ export async function runSchedulerTickOnce(
}
}
function reconcileOrphanedPairedReviewReadyTasks(
deps: SchedulerDependencies,
): void {
for (const task of getAllOpenPairedTasks()) {
if (task.status !== 'review_ready') {
continue;
}
if (hasActiveCiWatcherForChat(task.chat_jid)) {
continue;
}
const scheduled = schedulePairedFollowUpOnce({
chatJid: task.chat_jid,
runId: `scheduler-review-ready-${Date.now().toString(36)}`,
task,
intentKind: 'reviewer-turn',
enqueue: () =>
deps.queue.enqueueMessageCheck(
task.chat_jid,
resolveGroupIpcPath(task.group_folder),
),
});
if (!scheduled) {
continue;
}
logger.info(
{
taskId: task.id,
chatJid: task.chat_jid,
groupFolder: task.group_folder,
status: task.status,
},
'Re-queued orphaned review_ready paired task without active CI watcher',
);
}
}
let schedulerRunning = false;
let schedulerTimer: ReturnType<typeof setTimeout> | null = null;
let schedulerLoopFn: (() => Promise<void>) | null = null;