fix: add missing userMessageWasRemoved flag in manual retry for empty API responses#12291
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
fix: add missing userMessageWasRemoved flag in manual retry for empty API responses#12291roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
…I 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #12284
Description
This PR attempts to address Issue #12284. Feedback and guidance are welcome.
Bug found: When the API returns an empty response (no text or tool_use content), the user message is removed from
apiConversationHistorybefore retrying (line 3653). The auto-approval retry path correctly setsuserMessageWasRemoved: trueon the retry stack item, but the manual retry path (when user clicks "Retry") did not set this flag.This caused the retry loop to skip re-adding the user message to conversation history, resulting in the API being called without the user's context -- which would likely cause another empty response, creating a cascading failure loop.
Changes:
userMessageWasRemoved: trueto the manual retry stack push inTask.ts, matching the behavior already present in the auto-approval retry path.streamChunkCounttracking and aconsole.logwhen empty responses are detected, reporting chunk count, reasoning presence, and content block count. This helps diagnose whether the API returned truly nothing vs reasoning-only content.Test Procedure
cd src && npx vitest run core/task/__tests__/grace-retry-errors.spec.tsPre-Submission Checklist
Interactively review PR in Roo Code Cloud