fix(agent): retry latest provider error - #44
Conversation
|
Warning Review limit reached
Next review available in: 33 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe Agent chat now supports retrying the latest terminal provider error. Retry removes only the failed branch, preserves earlier messages, prevents duplicate user turns, and skips auto-compaction until the error is retried. ChangesAgent error retry behavior
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant User
participant ChatView
participant Agent
User->>ChatView: Click retry on latest provider error
ChatView->>ChatView: Remove failed branch and retain original request
ChatView->>Agent: Rerun original submission
Agent-->>ChatView: Continue agent response
ChatView-->>User: Render updated conversation
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/dao/browser/ui/webui/resources/agent/dao_chat_view.ts`:
- Around line 2468-2477: Update retryErrorById_ to use a synchronous in-flight
guard covering the entire retry transaction, preventing concurrent activations
from reaching retryFromUserIndex_ and agent.continue(); set the guard before any
await and clear it reliably after completion, while preserving the existing
retryability and final-message checks. Add a test that triggers two retry
activations and verifies only one retry request executes.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: f7e9ba45-d950-4f0f-8fc8-860c3fad703e
📒 Files selected for processing (6)
docs/feature-checklist.mddocs/features.mdsrc/dao/browser/ui/webui/resources/agent/__tests__/dao_chat_view.test.tssrc/dao/browser/ui/webui/resources/agent/dao_chat_view.tssrc/dao/browser/ui/webui/resources/agent/i18n/locales/en.tssrc/dao/browser/ui/webui/resources/agent/i18n/locales/zh-CN.ts
| private async retryErrorById_(errorId: string): Promise<void> { | ||
| const errorIdx = this.findMessageIndexByDaoId_(errorId); | ||
| const messages = this.currentMessages_(); | ||
| if (errorIdx !== messages.length - 1 || | ||
| !this.isRetryableAssistantError_(messages[errorIdx])) { | ||
| return; | ||
| } | ||
| await this.retryFromUserIndex_( | ||
| this.findUserIndexForAssistantIndex_(errorIdx)); | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Prevent concurrent retry execution.
Line 2475 calls retryFromUserIndex_, which checks agent.state.isStreaming before it awaits clearProactiveSuggestionForManualSend_(). Two quick activations can both pass that check and call agent.continue().
This can start duplicate provider requests for one failed submission. Add a synchronous in-flight guard around the full retry transaction. Add a double-activation test.
Proposed fix
+ private retryInFlight_ = false;
+
private async retryFromUserIndex_(userIdx: number): Promise<void> {
const agent = this.agent_;
- if (!agent || agent.state.isStreaming) return;
+ if (!agent || agent.state.isStreaming || this.retryInFlight_) return;
const messages = agent.state.messages;
if (userIdx < 0 || userIdx >= messages.length ||
!this.isUserMessage_(messages[userIdx])) {
return;
}
+ this.retryInFlight_ = true;
+ try {
agent.state.messages = messages.slice(0, userIdx + 1);
// ...
await this.clearProactiveSuggestionForManualSend_();
- try {
await agent.continue();
} catch (e) {
console.warn('[dao] retry failed', e);
this.scheduleSaveSession_();
+ } finally {
+ this.retryInFlight_ = false;
}
}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/dao/browser/ui/webui/resources/agent/dao_chat_view.ts` around lines 2468
- 2477, Update retryErrorById_ to use a synchronous in-flight guard covering the
entire retry transaction, preventing concurrent activations from reaching
retryFromUserIndex_ and agent.continue(); set the guard before any await and
clear it reliably after completion, while preserving the existing retryability
and final-message checks. Add a test that triggers two retry activations and
verifies only one retry request executes.
0f2d513 to
56f8c9a
Compare
56f8c9a to
5c77eab
Compare
Background
Provider failures at the end of an Agent conversation needed a retry path that preserves the original user submission and does not duplicate messages or rewrite earlier timeline entries.
Changes
Testing
Patch includes WebUI tests for retry visibility, retry timeline preservation, and auto-compaction behavior around retryable provider errors.
Summary by CodeRabbit
New Features
Bug Fixes
Documentation