Skip to content

fix(agent): retry latest provider error - #44

Merged
moonrailgun merged 1 commit into
mainfrom
agent-error-retry
Aug 7, 2026
Merged

fix(agent): retry latest provider error#44
moonrailgun merged 1 commit into
mainfrom
agent-error-retry

Conversation

@moonrailgun

@moonrailgun moonrailgun commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

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

  • Add a retry action only for the latest terminal provider error.
  • Reuse the original user or attachment submission when retrying and trim only the failed assistant/tool branch.
  • Prevent cancelled and historical assistant failures from showing retry actions.
  • Skip auto-compaction while a latest retryable provider error is present.
  • Update Agent feature docs, checklist coverage, and localized retry tooltip strings.

Testing

Patch includes WebUI tests for retry visibility, retry timeline preservation, and auto-compaction behavior around retryable provider errors.

Summary by CodeRabbit

  • New Features

    • Added the ability to retry terminal Agent chat provider errors using the original request.
    • Retry removes only the failed turn and partial follow-up output while preserving earlier conversation history.
    • Retry controls are shown only for the latest eligible error and are localized in English and Simplified Chinese.
  • Bug Fixes

    • Prevented retries for cancelled or historical errors.
    • Prevented automatic compaction from altering conversations ending in a retryable error.
  • Documentation

    • Documented Agent chat retry behavior and updated the feature checklist.

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@moonrailgun, you've reached your PR review limit, so we couldn't start this review.

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d33bcf42-c022-49fd-b2c3-7b0ed578d510

📥 Commits

Reviewing files that changed from the base of the PR and between 0f2d513 and 5c77eab.

📒 Files selected for processing (2)
  • src/dao/browser/ui/webui/resources/agent/__tests__/dao_chat_view.test.ts
  • src/dao/browser/ui/webui/resources/agent/dao_chat_view.ts
📝 Walkthrough

Walkthrough

The 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.

Changes

Agent error retry behavior

Layer / File(s) Summary
Retryability and compaction rules
src/dao/browser/ui/webui/resources/agent/dao_chat_view.ts, src/dao/browser/ui/webui/resources/agent/__tests__/dao_chat_view.test.ts
Chat messages store provider error text. The latest retryable error is excluded from automatic compaction. Tests cover this behavior.
Retry action and execution
src/dao/browser/ui/webui/resources/agent/dao_chat_view.ts, src/dao/browser/ui/webui/resources/agent/__tests__/dao_chat_view.test.ts, src/dao/browser/ui/webui/resources/agent/i18n/locales/*.ts, docs/features.md, docs/feature-checklist.md
The UI shows retry only for the latest eligible provider error. Retry removes the failed branch, preserves the original request and earlier messages, and continues the agent without duplicating the user turn. Documentation and translations describe the feature.

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
Loading

Possibly related PRs

  • msgbyte/dao-browser#9: Both changes modify post-turn auto-compaction behavior in dao_chat_view.ts and its tests.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the primary change: retrying the latest provider error in Agent conversations.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent-error-retry

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between d8b600c and 0f2d513.

📒 Files selected for processing (6)
  • docs/feature-checklist.md
  • docs/features.md
  • src/dao/browser/ui/webui/resources/agent/__tests__/dao_chat_view.test.ts
  • src/dao/browser/ui/webui/resources/agent/dao_chat_view.ts
  • src/dao/browser/ui/webui/resources/agent/i18n/locales/en.ts
  • src/dao/browser/ui/webui/resources/agent/i18n/locales/zh-CN.ts

Comment on lines +2468 to +2477
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));
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🩺 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.

@moonrailgun
moonrailgun merged commit 3701952 into main Aug 7, 2026
2 checks passed
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.

1 participant