Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

mrcabbage972
Copy link
Contributor

@mrcabbage972 mrcabbage972 commented Oct 9, 2025

TLDR

This PR introduces a new feature to automatically "retry" a model call when the response stream terminates unexpectedly.

  1. New Config Flag: A continueOnFailedApiCall flag (defaults to true) is added to control this behavior.
  2. Retry Logic: If the flag is enabled and an InvalidStream event occurs, the client will automatically send the prompt "Please continue." to try and recover the rest of the model's response.
  3. Safeguard: This retry mechanism will only execute once per user request.

Dive Deeper

Reviewer Test Plan

Testing Matrix

🍏 🪟 🐧
npm run
npx
Docker
Podman - -
Seatbelt - -

Linked issues / bugs

Copy link

github-actions bot commented Oct 9, 2025

Size Change: +1.51 kB (+0.01%)

Total Size: 17.7 MB

Filename Size Change
./bundle/gemini.js 17.7 MB +1.51 kB (+0.01%)
ℹ️ View Unchanged
Filename Size
./bundle/sandbox-macos-permissive-closed.sb 1.03 kB
./bundle/sandbox-macos-permissive-open.sb 830 B
./bundle/sandbox-macos-permissive-proxied.sb 1.31 kB
./bundle/sandbox-macos-restrictive-closed.sb 3.29 kB
./bundle/sandbox-macos-restrictive-open.sb 3.36 kB
./bundle/sandbox-macos-restrictive-proxied.sb 3.56 kB

compressed-size-action

@mrcabbage972 mrcabbage972 changed the title Empty Response Workaround feat(core): Empty Response Workaround Oct 9, 2025
@mrcabbage972 mrcabbage972 marked this pull request as ready for review October 9, 2025 20:15
@mrcabbage972 mrcabbage972 requested a review from a team as a code owner October 9, 2025 20:15
@mrcabbage972 mrcabbage972 changed the title feat(core): Empty Response Workaround feat(core): Failed Response Retry vs Extra Prompt Oct 9, 2025
@mrcabbage972 mrcabbage972 changed the title feat(core): Failed Response Retry vs Extra Prompt feat(core): Failed Response Retry via Extra Prompt Oct 9, 2025
boundedTurns - 1,
// isInvalidStreamRetry is false here, as this is a next speaker check
);
if (this.config.getContinueOnFailedApiCall()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not necessary here since we now won don't run the next speaker check anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thx

);
return turn;
}
const nextRequest = [{ text: 'Please continue.' }];
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we say "System: Please continue"? This disambiguates from the user and won't be confusing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

this.enableMessageBusIntegration =
params.enableMessageBusIntegration ?? false;
this.enableSubagents = params.enableSubagents ?? false;
this.continueOnFailedApiCall = params.continueOnFailedApiCall ?? false;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to turn this on by default to get immediate metrics?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@mrcabbage972
Copy link
Contributor Author

/gemini review

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a valuable feature to automatically retry a model call when the response stream terminates unexpectedly, controlled by a new continueOnFailedApiCall flag. The implementation is mostly sound, with new configurations, core client logic, and tests. However, I've found a few critical and high-severity issues. The new configuration flag incorrectly defaults to true instead of false, which is a critical issue. Additionally, there are inconsistencies in the retry prompt and incorrect hardcoded values in telemetry logging that should be addressed to ensure correctness and maintainability.

packages/core/src/config/config.ts Show resolved Hide resolved
);
return turn;
}
const nextRequest = [{ text: 'System: Please continue.' }];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The retry prompt includes a "System: " prefix, which is inconsistent with other parts of the code that send a continuation prompt (e.g., the nextSpeakerCheck logic, which just sends "Please continue."). This inconsistency might confuse the model and lead to unexpected behavior. It's better to use a consistent prompt for continuations.

Suggested change
const nextRequest = [{ text: 'System: Please continue.' }];
const nextRequest = [{ text: 'Please continue.' }];

Comment on lines +598 to +602
new ContentRetryFailureEvent(
4, // 2 initial + 2 after injections
'FAILED_AFTER_PROMPT_INJECTION',
modelToUse,
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The total_attempts in this ContentRetryFailureEvent is hardcoded to 4. According to the logic, there is only one retry attempt, so the total number of attempts should be 2 (1 initial + 1 retry). The comment // 2 initial + 2 after injections is also unclear and doesn't seem to match the logic here. Please correct the number of attempts to reflect the actual behavior.

Suggested change
new ContentRetryFailureEvent(
4, // 2 initial + 2 after injections
'FAILED_AFTER_PROMPT_INJECTION',
modelToUse,
),
new ContentRetryFailureEvent(
2, // 1 initial + 1 retry
'FAILED_AFTER_PROMPT_INJECTION',
modelToUse,
),

@mrcabbage972 mrcabbage972 added this pull request to the merge queue Oct 9, 2025
Merged via the queue into main with commit 0b6c020 Oct 9, 2025
20 checks passed
@mrcabbage972 mrcabbage972 deleted the mrcabbage972/empty-stream-plz-continue branch October 9, 2025 22:11
giraffe-tree pushed a commit to giraffe-tree/gemini-cli that referenced this pull request Oct 10, 2025
Co-authored-by: Sandy Tao <sandytao520@icloud.com>
SandyTao520 added a commit that referenced this pull request Oct 10, 2025
Co-authored-by: Sandy Tao <sandytao520@icloud.com>
@mrcabbage972
Copy link
Contributor Author

/patch preview

Copy link

Patch workflow(s) dispatched successfully!

📋 Details:

  • Channels: preview
  • Commit: 0b6c02000f2301717c38fb3c8ba2423d70d6c0b0
  • Workflows Created: 1

🔗 Track Progress:

github-actions bot pushed a commit that referenced this pull request Oct 10, 2025
Co-authored-by: Sandy Tao <sandytao520@icloud.com>
# Conflicts:
#	packages/core/src/core/turn.ts
Copy link

🚀 Patch PR Created!

📋 Patch Details:

📝 Next Steps:

  1. ⚠️ Resolve conflicts in the hotfix PR first: #10920
  2. Test your changes after resolving conflicts
  3. Once merged, the patch release will automatically trigger
  4. You'll receive updates here when the release completes

🔗 Track Progress:

Copy link

🚀 Patch Release Started!

📋 Release Details:

⏳ Status: The patch release is now running. You'll receive another update when it completes.

🔗 Track Progress:

Copy link

Patch Release Failed!

📋 Details:

  • Version: 0.9.0-preview.2
  • Channel: preview
  • Error: The patch release workflow encountered an error

🔍 Next Steps:

  1. Check the workflow logs for detailed error information
  2. The maintainers have been notified via automatic issue creation
  3. You may need to retry the patch once the issue is resolved

🔗 Troubleshooting:

Copy link

Patch Release Complete!

📦 Release Details:

  • Version: 0.9.0-preview.2
  • NPM Tag: preview
  • Channel: preview
  • Dry Run: false

🎉 Status: Your patch has been successfully released and published to npm!

📝 What's Available:

🔗 Links:

thacio added a commit to thacio/auditaria that referenced this pull request Oct 11, 2025
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.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.