diff --git a/src/paired-execution-context.ts b/src/paired-execution-context.ts index 3a73b72..25aa214 100644 --- a/src/paired-execution-context.ts +++ b/src/paired-execution-context.ts @@ -223,11 +223,22 @@ export function completePairedExecutionContext(args: { 'Paired execution completed', ); - if (status !== 'succeeded') return; - const task = getPairedTaskById(taskId); if (!task) return; + // On failure, reset task to active so the flow isn't stuck + if (status !== 'succeeded') { + if (task.status !== 'active') { + const now = new Date().toISOString(); + updatePairedTask(taskId, { status: 'active', updated_at: now }); + logger.info( + { taskId, role, previousStatus: task.status }, + 'Reset task to active after failed execution', + ); + } + return; + } + // Owner finished → auto-trigger reviewer (if within round trip limit) if (role === 'owner') { if (task.round_trip_count >= PAIRED_MAX_ROUND_TRIPS) {