-
Notifications
You must be signed in to change notification settings - Fork 8.7k
feat(core): Failed Response Retry via Extra Prompt #10828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Size Change: +1.51 kB (+0.01%) Total Size: 17.7 MB
ℹ️ View Unchanged
|
packages/core/src/core/client.ts
Outdated
boundedTurns - 1, | ||
// isInvalidStreamRetry is false here, as this is a next speaker check | ||
); | ||
if (this.config.getContinueOnFailedApiCall()) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thx
packages/core/src/core/client.ts
Outdated
); | ||
return turn; | ||
} | ||
const nextRequest = [{ text: 'Please continue.' }]; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
packages/core/src/config/config.ts
Outdated
this.enableMessageBusIntegration = | ||
params.enableMessageBusIntegration ?? false; | ||
this.enableSubagents = params.enableSubagents ?? false; | ||
this.continueOnFailedApiCall = params.continueOnFailedApiCall ?? false; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
/gemini review |
There was a problem hiding this 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.
); | ||
return turn; | ||
} | ||
const nextRequest = [{ text: 'System: Please continue.' }]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
const nextRequest = [{ text: 'System: Please continue.' }]; | |
const nextRequest = [{ text: 'Please continue.' }]; |
new ContentRetryFailureEvent( | ||
4, // 2 initial + 2 after injections | ||
'FAILED_AFTER_PROMPT_INJECTION', | ||
modelToUse, | ||
), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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, | |
), |
Co-authored-by: Sandy Tao <sandytao520@icloud.com>
Co-authored-by: Sandy Tao <sandytao520@icloud.com>
/patch preview |
✅ Patch workflow(s) dispatched successfully! 📋 Details:
🔗 Track Progress: |
Co-authored-by: Sandy Tao <sandytao520@icloud.com> # Conflicts: # packages/core/src/core/turn.ts
🚀 Patch PR Created! 📋 Patch Details:
📝 Next Steps:
🔗 Track Progress: |
🚀 Patch Release Started! 📋 Release Details:
⏳ Status: The patch release is now running. You'll receive another update when it completes. 🔗 Track Progress: |
❌ Patch Release Failed! 📋 Details:
🔍 Next Steps:
🔗 Troubleshooting: |
✅ Patch Release Complete! 📦 Release Details:
🎉 Status: Your patch has been successfully released and published to npm! 📝 What's Available:
🔗 Links: |
TLDR
This PR introduces a new feature to automatically "retry" a model call when the response stream terminates unexpectedly.
Dive Deeper
Reviewer Test Plan
Testing Matrix
Linked issues / bugs