Explorar o código

Fix instructions about continuing write_to_file on recently cancelled edit

Saoud Rizwan hai 1 ano
pai
achega
d422afda8f
Modificáronse 1 ficheiros con 7 adicións e 1 borrados
  1. 7 1
      src/core/Cline.ts

+ 7 - 1
src/core/Cline.ts

@@ -600,10 +600,16 @@ export class Cline {
 			return "just now"
 			return "just now"
 		})()
 		})()
 
 
+		const wasRecent = lastClineMessage?.ts && Date.now() - lastClineMessage.ts < 30_000
+
 		newUserContent.push({
 		newUserContent.push({
 			type: "text",
 			type: "text",
 			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. The current working directory is now '${cwd.toPosix()}'. If the task has not been completed, retry the last step before interruption and proceed with completing the task. Note: 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.` +
+				`[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. The current working directory is now '${cwd.toPosix()}'. 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.${
+					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
 				(responseText
 					? `\n\nNew instructions for task continuation:\n<user_message>\n${responseText}\n</user_message>`
 					? `\n\nNew instructions for task continuation:\n<user_message>\n${responseText}\n</user_message>`
 					: ""),
 					: ""),