Sfoglia il codice sorgente

fix: prevent duplicate errors in plan mode restriction messages (#8677)

Fix error message handling during streaming by removing previous partial
error messages and only pushing the final error result when streaming is
complete. This prevents multiple error messages from being displayed for
the same plan mode tool restriction and ensures errors are only finalized
after streaming ends.
Bee 1 settimana fa
parent
commit
bffe5c4d2a
1 ha cambiato i file con 5 aggiunte e 1 eliminazioni
  1. 5 1
      src/core/task/ToolExecutor.ts

+ 5 - 1
src/core/task/ToolExecutor.ts

@@ -375,8 +375,12 @@ export class ToolExecutor {
 				this.isPlanModeToolRestricted(block.name)
 			) {
 				const errorMessage = `Tool '${block.name}' is not available in PLAN MODE. This tool is restricted to ACT MODE for file modifications. Only use tools available for PLAN MODE when in that mode.`
+				await this.removeLastPartialMessageIfExistsWithType("say", "error")
 				await this.say("error", errorMessage)
-				this.pushToolResult(formatResponse.toolError(errorMessage), block)
+				// Only push the final error message when the streaming is done.
+				if (!block.partial) {
+					this.pushToolResult(formatResponse.toolError(errorMessage), block)
+				}
 				return true
 			}