Skip to content

Commit bca20e5

Browse files
mrubensbrunobergher
authored andcommitted
Include reasoning messages in cloud tasks (#8401)
1 parent 1e287f9 commit bca20e5

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/core/task/Task.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2252,6 +2252,22 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
22522252
// Note: updateApiReqMsg() is now called from within drainStreamInBackgroundToFindAllUsage
22532253
// to ensure usage data is captured even when the stream is interrupted. The background task
22542254
// uses local variables to accumulate usage data before atomically updating the shared state.
2255+
2256+
// Complete the reasoning message if it exists
2257+
// We can't use say() here because the reasoning message may not be the last message
2258+
// (other messages like text blocks or tool uses may have been added after it during streaming)
2259+
if (reasoningMessage) {
2260+
const lastReasoningIndex = findLastIndex(
2261+
this.clineMessages,
2262+
(m) => m.type === "say" && m.say === "reasoning",
2263+
)
2264+
2265+
if (lastReasoningIndex !== -1 && this.clineMessages[lastReasoningIndex].partial) {
2266+
this.clineMessages[lastReasoningIndex].partial = false
2267+
await this.updateClineMessage(this.clineMessages[lastReasoningIndex])
2268+
}
2269+
}
2270+
22552271
await this.persistGpt5Metadata(reasoningMessage)
22562272
await this.saveClineMessages()
22572273
await this.providerRef.deref()?.postStateToWebview()

0 commit comments

Comments
 (0)