From 0d234e7281ee354905ab8bd6889e6dbde451ff17 Mon Sep 17 00:00:00 2001 From: Eric Wheeler Date: Thu, 17 Jul 2025 16:18:43 -0700 Subject: [PATCH 1/3] fix: Remove misleading task resumption message This commit removes the misleading [TASK RESUMPTION] message that appears when a task is interrupted. The message was confusing the model and triggering unnecessary re-reads by suggesting things had changed when they hadn't. will always be provided fresh with any necessary information, so the model should assume tasks are up to date. Fixes: #5850 Signed-off-by: Eric Wheeler --- src/core/task/Task.ts | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 8a1bf1101d4..12180934630 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -987,26 +987,11 @@ export class Task extends EventEmitter { return "just now" })() - const lastTaskResumptionIndex = newUserContent.findIndex( - (x) => x.type === "text" && x.text.startsWith("[TASK RESUMPTION]"), - ) - if (lastTaskResumptionIndex !== -1) { - newUserContent.splice(lastTaskResumptionIndex, newUserContent.length - lastTaskResumptionIndex) - } - - const wasRecent = lastClineMessage?.ts && Date.now() - lastClineMessage.ts < 30_000 - newUserContent.push({ type: "text", - text: - `[TASK RESUMPTION] This task was interrupted ${agoText}. It may or may not be complete, so please reassess the task context. Be aware that the project state may have changed since then. If the task has not been completed, retry the last step before interruption and proceed with completing the task.\n\nNote: If you previously attempted a tool use that the user did not provide a result for, you should assume the tool use was not successful and assess whether you should retry. If the last tool was a browser_action, the browser has been closed and you must launch a new browser if needed.${ - wasRecent - ? "\n\nIMPORTANT: If the last tool use was a write_to_file that was interrupted, the file was reverted back to its original state before the interrupted edit, and you do NOT need to re-read the file as you already have its up-to-date contents." - : "" - }` + - (responseText - ? `\n\nNew instructions for task continuation:\n\n${responseText}\n` - : ""), + text: responseText + ? `\n\nNew instructions for task continuation:\n\n${responseText}\n` + : "", }) if (responseImages && responseImages.length > 0) { From 0e8654999bb007334a82f6f9e1d31611ed907a07 Mon Sep 17 00:00:00 2001 From: Daniel Riccio Date: Thu, 17 Jul 2025 19:37:04 -0500 Subject: [PATCH 2/3] fix: only add text block to newUserContent when responseText has content This prevents the API error 'text content blocks must be non-empty' that occurs when resuming a task without providing new instructions. --- src/core/task/Task.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 12180934630..8cce0dfd2a8 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -987,12 +987,12 @@ export class Task extends EventEmitter { return "just now" })() - newUserContent.push({ - type: "text", - text: responseText - ? `\n\nNew instructions for task continuation:\n\n${responseText}\n` - : "", - }) + if (responseText) { + newUserContent.push({ + type: "text", + text: `\n\nNew instructions for task continuation:\n\n${responseText}\n`, + }) + } if (responseImages && responseImages.length > 0) { newUserContent.push(...formatResponse.imageBlocks(responseImages)) From c5c7adc744a8bf5a53b6ac09e043e7bef0136933 Mon Sep 17 00:00:00 2001 From: Daniel Riccio Date: Thu, 17 Jul 2025 19:41:49 -0500 Subject: [PATCH 3/3] fix: ensure newUserContent is never empty when resuming tasks Added a check to ensure that newUserContent always has at least one text block when calling initiateTaskLoop. This prevents the 'text content blocks must be non-empty' API error when resuming a task with no response text or images. --- src/core/task/Task.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 8cce0dfd2a8..b1fde1e8932 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -998,6 +998,15 @@ export class Task extends EventEmitter { newUserContent.push(...formatResponse.imageBlocks(responseImages)) } + // Ensure we have at least some content to send to the API + // If newUserContent is empty, add a minimal resumption message + if (newUserContent.length === 0) { + newUserContent.push({ + type: "text", + text: "[TASK RESUMPTION] Resuming task...", + }) + } + await this.overwriteApiConversationHistory(modifiedApiConversationHistory) console.log(`[subtasks] task ${this.taskId}.${this.instanceId} resuming from history item`)