From 01f5320b4d4179779c4e1740888d1c3e8defdeff Mon Sep 17 00:00:00 2001 From: KJ7LNW <93454819+KJ7LNW@users.noreply.github.com> Date: Wed, 30 Jul 2025 19:53:06 -0700 Subject: [PATCH] fix: Remove misleading task resumption message (#5851) Co-authored-by: Eric Wheeler Co-authored-by: Daniel Riccio --- src/core/task/Task.ts | 34 ++++++++++++++-------------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 38c67b5021..9d68640fd8 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -1170,32 +1170,26 @@ 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) + if (responseText) { + newUserContent.push({ + type: "text", + text: `\n\nNew instructions for task continuation:\n\n${responseText}\n`, + }) } - 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` - : ""), - }) - if (responseImages && responseImages.length > 0) { 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`)