From 9a2aaf088140f511fa8abdf43ab7889c47dbf686 Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Thu, 14 Aug 2025 22:35:19 -0700 Subject: [PATCH] fix: attempt_completion showing twice in chat due to partial logic not being handled correctly (#5588) * fix: attempt_completion showing twice in chat due to partial logic not being handled correctly * Create orange-beds-itch.md --- .changeset/orange-beds-itch.md | 5 +++++ src/core/task/ToolExecutor.ts | 23 ++++++++++++----------- 2 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 .changeset/orange-beds-itch.md diff --git a/.changeset/orange-beds-itch.md b/.changeset/orange-beds-itch.md new file mode 100644 index 00000000..d84d1d58 --- /dev/null +++ b/.changeset/orange-beds-itch.md @@ -0,0 +1,5 @@ +--- +"claude-dev": patch +--- + +Fix attempt_completion showing twice in chat due to partial logic not being handled correctly diff --git a/src/core/task/ToolExecutor.ts b/src/core/task/ToolExecutor.ts index d7158111..0ddca958 100644 --- a/src/core/task/ToolExecutor.ts +++ b/src/core/task/ToolExecutor.ts @@ -2235,17 +2235,18 @@ export class ToolExecutor { // () => {}, // ) } else { - // last message is completion_result - // we have command string, which means we have the result as well, so finish it (doesn't have to exist yet) - await this.say( - "completion_result", - this.removeClosingTag(block, "result", result), - undefined, - undefined, - false, - ) - await this.saveCheckpoint(true) - await addNewChangesFlagToLastCompletionResultMessage() + // Now that we don't stream a command, we shouldn't be completing the attempt_completion tool in the block.partial conditional, and instead do it when partial is false below + // + // last message is completion_result, we have command string, which means we have the result as well, so finish it (doesn't have to exist yet) + // await this.say( + // "completion_result", + // this.removeClosingTag(block, "result", result), + // undefined, + // undefined, + // false, + // ) + // await this.saveCheckpoint(true) + // await addNewChangesFlagToLastCompletionResultMessage() // await this.ask("command", this.removeClosingTag(block, "command", command), block.partial).catch( // () => {}, // )