From 4d402ab99c47104e4cc993b8c24ddd8a935485ff Mon Sep 17 00:00:00 2001 From: Matt Rubens Date: Tue, 30 Sep 2025 01:11:27 -0400 Subject: [PATCH] Include reasoning messages in cloud tasks --- src/core/task/Task.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/core/task/Task.ts b/src/core/task/Task.ts index 2dd9e55c0b..851df91e6c 100644 --- a/src/core/task/Task.ts +++ b/src/core/task/Task.ts @@ -2252,6 +2252,22 @@ export class Task extends EventEmitter implements TaskLike { // Note: updateApiReqMsg() is now called from within drainStreamInBackgroundToFindAllUsage // to ensure usage data is captured even when the stream is interrupted. The background task // uses local variables to accumulate usage data before atomically updating the shared state. + + // Complete the reasoning message if it exists + // We can't use say() here because the reasoning message may not be the last message + // (other messages like text blocks or tool uses may have been added after it during streaming) + if (reasoningMessage) { + const lastReasoningIndex = findLastIndex( + this.clineMessages, + (m) => m.type === "say" && m.say === "reasoning", + ) + + if (lastReasoningIndex !== -1 && this.clineMessages[lastReasoningIndex].partial) { + this.clineMessages[lastReasoningIndex].partial = false + await this.updateClineMessage(this.clineMessages[lastReasoningIndex]) + } + } + await this.persistGpt5Metadata(reasoningMessage) await this.saveClineMessages() await this.providerRef.deref()?.postStateToWebview()