fix: Remove misleading task resumption message (#5851)

Co-authored-by: Eric Wheeler <roo-code@z.ewheeler.org>
Co-authored-by: Daniel Riccio <ricciodaniel98@gmail.com>
This commit is contained in:
KJ7LNW 2025-07-30 19:53:06 -07:00 committed by GitHub
parent b7410dce8c
commit 01f5320b4d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1170,32 +1170,26 @@ export class Task extends EventEmitter<TaskEvents> {
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<user_message>\n${responseText}\n</user_message>`,
})
}
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<user_message>\n${responseText}\n</user_message>`
: ""),
})
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`)