Skip to content

fix: add missing userMessageWasRemoved flag in manual retry for empty API responses#12291

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/empty-api-response-retry-12284
Draft

fix: add missing userMessageWasRemoved flag in manual retry for empty API responses#12291
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/empty-api-response-retry-12284

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 Bot commented May 8, 2026

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 apiConversationHistory before retrying (line 3653). The auto-approval retry path correctly sets userMessageWasRemoved: true on 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:

  1. Bug fix: Added userMessageWasRemoved: true to the manual retry stack push in Task.ts, matching the behavior already present in the auto-approval retry path.
  2. Diagnostic logging: Added streamChunkCount tracking and a console.log when 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

  • Existing grace-retry tests pass (11/11): cd src && npx vitest run core/task/__tests__/grace-retry-errors.spec.ts
  • All lint and type checks pass
  • Manual verification: when API returns empty response and user clicks Retry, the user message is now correctly re-added to conversation history

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue.
  • Scope: Changes are focused on the linked issue.
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: Existing tests pass; the fix is a single-line property addition that is validated by the existing retry flow.
  • Documentation Impact: No documentation updates needed.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Interactively review PR in Roo Code Cloud

…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Unexpected API Response: The language model did not provide any assistant messages. This may indicate an issue with the API or the model's output.

1 participant