task_retry
Retry failed or crashed tasks in the SFTP Orchestrator to maintain workflow continuity and resolve execution issues.
Instructions
Relance une tâche qui a échoué ou crashé.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | L'ID de la tâche à réessayer. |
Implementation Reference
- server.js:649-681 (registration)Registration of the task_retry tool including schema and handler function.server.registerTool( "task_retry", { title: "Réessayer une tâche échouée", description: "Relance une tâche qui a échoué ou crashé.", inputSchema: z.object({ id: z.string().describe("L'ID de la tâche à réessayer.") }) }, async (params) => { try { const newJob = await queue.retryJob(params.id); // Relancer selon le type if (newJob.type === 'sftp') { sftp.executeTransfer(newJob.id); } else if (newJob.type === 'ssh') { ssh.executeCommand(newJob.id); } else if (newJob.type === 'ssh_sequence') { ssh.executeCommandSequence(newJob.id); } return { content: [{ type: "text", text: `Tâche ${params.id} relancée avec le nouvel ID: ${newJob.id}` }] }; } catch (e) { const errorPayload = { toolName: "task_retry", errorCode: "TOOL_EXECUTION_ERROR", errorMessage: e.message }; return { content: [{ type: "text", text: JSON.stringify(errorPayload, null, 2) }], isError: true }; } } );
- queue.js:247-283 (helper)Core retryJob function that creates a new pending job from a failed or crashed one, increments retry count, and handles limits.async function retryJob(id) { const job = jobQueue[id]; if (!job) { throw new Error(`Tâche ${id} introuvable`); } if (!['failed', 'crashed'].includes(job.status)) { throw new Error(`La tâche ${id} ne peut pas être réessayée (statut: ${job.status})`); } if (job.retryCount >= job.maxRetries) { throw new Error(`La tâche ${id} a atteint le nombre max de tentatives (${job.maxRetries})`); } const newJob = { ...job, id: uuidv4().split('-')[0], status: 'pending', retryCount: (job.retryCount || 0) + 1, retriedFrom: id, createdAt: new Date(), updatedAt: new Date(), error: null, output: null }; delete newJob.failedAt; delete newJob.crashedAt; delete newJob.completedAt; jobQueue[newJob.id] = newJob; isDirty = true; log('info', `Tâche ${id} réessayée -> nouvelle tâche ${newJob.id} (tentative ${newJob.retryCount}/${newJob.maxRetries})`); return newJob; }