mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: prevent AI from getting stuck when assistantMessageContent is empty
- Add early check for empty content when streaming is complete - Ensure userMessageContentReady is set even with no content - Add additional safety check for edge cases - Improve handling of partial blocks with pending updates Fixes #9702
This commit is contained in:
parent
4591e960ed
commit
8ad040ec4c
1 changed files with 19 additions and 3 deletions
|
|
@ -73,6 +73,14 @@ export async function presentAssistantMessage(cline: Task) {
|
|||
cline.presentAssistantMessageLocked = true
|
||||
cline.presentAssistantMessageHasPendingUpdates = false
|
||||
|
||||
// Handle empty content case immediately
|
||||
if (cline.assistantMessageContent.length === 0 && cline.didCompleteReadingStream) {
|
||||
// If there's no content and streaming is complete, mark as ready
|
||||
cline.userMessageContentReady = true
|
||||
cline.presentAssistantMessageLocked = false
|
||||
return
|
||||
}
|
||||
|
||||
if (cline.currentStreamingContentIndex >= cline.assistantMessageContent.length) {
|
||||
// This may happen if the last content block was completed before
|
||||
// streaming could finish. If streaming is finished, and we're out of
|
||||
|
|
@ -1064,11 +1072,19 @@ export async function presentAssistantMessage(cline: Task) {
|
|||
cline.userMessageContentReady = true
|
||||
}
|
||||
}
|
||||
} else if (block.partial && cline.presentAssistantMessageHasPendingUpdates) {
|
||||
// Block is partial, but the read stream may have finished or has pending updates
|
||||
presentAssistantMessage(cline)
|
||||
}
|
||||
|
||||
// Block is partial, but the read stream may have finished.
|
||||
if (cline.presentAssistantMessageHasPendingUpdates) {
|
||||
presentAssistantMessage(cline)
|
||||
// Additional safety check: If streaming is complete but we haven't set userMessageContentReady yet
|
||||
// This can happen if the last block was partial and didn't trigger the normal completion flow
|
||||
if (
|
||||
cline.didCompleteReadingStream &&
|
||||
!cline.userMessageContentReady &&
|
||||
cline.assistantMessageContent.length === 0
|
||||
) {
|
||||
cline.userMessageContentReady = true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue