From 7f05e06d8e83deb991ebfe5bdaa89d9c34a9bcc4 Mon Sep 17 00:00:00 2001 From: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com> Date: Thu, 9 Oct 2025 16:21:32 -0700 Subject: [PATCH] Update plan mode response with latest content and `partial = false` in yolo mode (#6737) --- .../tools/handlers/PlanModeRespondHandler.ts | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/core/task/tools/handlers/PlanModeRespondHandler.ts b/src/core/task/tools/handlers/PlanModeRespondHandler.ts index f981290b..718b2b46 100644 --- a/src/core/task/tools/handlers/PlanModeRespondHandler.ts +++ b/src/core/task/tools/handlers/PlanModeRespondHandler.ts @@ -61,12 +61,27 @@ export class PlanModeRespondHandler implements IToolHandler, IPartialBlockHandle // Store the number of options for telemetry const options = parsePartialArrayString(optionsRaw || "[]") + const sharedMessage = { + response: response, + options: options, + } + // Auto-switch to Act mode while in yolo mode if (config.mode === "plan" && config.yoloModeToggled && !needsMoreExploration) { // Trigger automatic mode switch const switchSuccessful = await config.callbacks.switchToActMode() if (switchSuccessful) { + // Complete the plan mode response tool call (this is a unique case where we auto-respond to the user with an ask response) + const lastPlanMessage = findLast(config.messageState.getClineMessages(), (m: any) => m.ask === this.name) + if (lastPlanMessage) { + lastPlanMessage.text = JSON.stringify({ + ...sharedMessage, + } satisfies ClinePlanModeResponse) + lastPlanMessage.partial = false + await config.messageState.saveClineMessagesAndUpdateHistory() + } + // we dont need to process any text, options, files or other content here return formatResponse.toolResult(`[The user has switched to ACT MODE, so you may now proceed with the task.]`) } else { @@ -77,11 +92,6 @@ export class PlanModeRespondHandler implements IToolHandler, IPartialBlockHandle // Set awaiting plan response state config.taskState.isAwaitingPlanResponse = true - const sharedMessage = { - response: response, - options: options, - } - // Ask for user response let { text,