mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-08-28 05:27:24 +00:00
fix: add userMessageWasRemoved flag to manual retry path for empty API responses
When the API returns an empty response (no text or tool_use content), the user message is removed from apiConversationHistory before retrying. The auto-approval retry path correctly set userMessageWasRemoved: true on the retry stack item, but the manual retry path (when user clicks Retry) did not. This caused the retry loop to skip re-adding the user message, resulting in broken conversation history and cascading empty responses. Also adds diagnostic logging when empty responses are detected, tracking stream chunk count, reasoning presence, and content block count to help diagnose transient API issues. Fixes #12284
This commit is contained in:
parent
ad25634905
commit
d2467c4f0d
1 changed files with 7 additions and 0 deletions
|
|
@ -2792,6 +2792,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
let assistantMessage = ""
|
||||
let reasoningMessage = ""
|
||||
let pendingGroundingSources: GroundingSource[] = []
|
||||
let streamChunkCount = 0
|
||||
this.isStreaming = true
|
||||
|
||||
try {
|
||||
|
|
@ -2830,6 +2831,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
continue
|
||||
}
|
||||
|
||||
streamChunkCount++
|
||||
switch (chunk.type) {
|
||||
case "reasoning": {
|
||||
reasoningMessage += chunk.text
|
||||
|
|
@ -3632,6 +3634,9 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
// or tool_use content blocks from API which we should assume is
|
||||
// an error.
|
||||
|
||||
console.log(
|
||||
`[Task#${this.taskId}.${this.instanceId}] Empty API response: streamChunks=${streamChunkCount}, hasReasoning=${reasoningMessage.length > 0}, contentBlocks=${this.assistantMessageContent.length}`,
|
||||
)
|
||||
// Increment consecutive no-assistant-messages counter
|
||||
this.consecutiveNoAssistantMessagesCount++
|
||||
|
||||
|
|
@ -3695,10 +3700,12 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
|
|||
await this.say("api_req_retried")
|
||||
|
||||
// Push the same content back to retry
|
||||
// Mark that user message was removed so it gets re-added on retry
|
||||
stack.push({
|
||||
userContent: currentUserContent,
|
||||
includeFileDetails: false,
|
||||
retryAttempt: (currentItem.retryAttempt ?? 0) + 1,
|
||||
userMessageWasRemoved: true,
|
||||
})
|
||||
|
||||
// Continue to retry the request
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue