Skip to content

Fix provider retry waiting feedback - #2225

Merged
zhangmo8 merged 3 commits into
devfrom
fix/issue-2221-provider-retry-waiting
Aug 31, 2026
Merged

Fix provider retry waiting feedback#2225
zhangmo8 merged 3 commits into
devfrom
fix/issue-2221-provider-retry-waiting

Conversation

@zhangmo8

@zhangmo8 zhangmo8 commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Show a temporary rate-limit status while a provider request is waiting to retry, then clear it when retry starts, finishes, aborts, or the run exits. Provider retry payloads stay separate from local QPS queue fields, and a harness regression test covers the full publish-and-clear flow.

Fixes #2221

Tests:

  • pnpm exec vitest run --config vitest.config.ts test/main/agent/deepchat/harness/deepChatAgentHarness.test.ts test/main/agent/deepchat/runtime/deepChatLoopRunner.test.ts
  • git diff --check

Summary by CodeRabbit

  • New Features

    • Added a temporary status indicator while a provider waits to retry a request.
    • The indicator shows the estimated wait time and clears automatically when retrying begins or completes.
    • Rate-limit details appear only when available.
  • Bug Fixes

    • Improved retry status handling to prevent stale waiting messages, including during cancellation or consecutive retries.
  • Tests

    • Added coverage for retry notifications, clearing behavior, cancellation, and provider recovery.

Publish a temporary stream update while provider retries so the UI remains responsive.

Fixes #2221
@coderabbitai

coderabbitai Bot commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e77df01c-ac6d-4097-a715-19a3db8b3b35

📥 Commits

Reviewing files that changed from the base of the PR and between bb6ab09 and dac59bb.

📒 Files selected for processing (1)
  • test/main/agent/deepchat/harness/deepChatAgentHarness.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/main/agent/deepchat/harness/deepChatAgentHarness.test.ts

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

DeepChatLoopRunner now reports provider retry delays through an ephemeral rate-limit message. It clears the message when retries start, finish, abort, or when the run exits. Waiting blocks omit undefined queue metrics. Tests cover consecutive retries and cancellation.

Changes

Provider retry waiting

Layer / File(s) Summary
Retry waiting lifecycle
src/main/agent/deepchat/runtime/deepChatLoopRunner.ts
The runner tracks provider retry waiting state, emits updates for scheduled retries, clears them at retry transitions, and removes the abort listener during cleanup.
Waiting message contract and validation
src/main/agent/deepchat/runtime/deepChatLoopRunner.ts, test/main/agent/deepchat/harness/deepChatAgentHarness.test.ts
Waiting blocks conditionally include queue metrics. The harness verifies consecutive retries, event sequences, provider call counts, and cancellation cleanup.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to dac59

The change shows and clears temporary provider retry status across the retry lifecycle; no actionable merge-blocking risk remains beyond normal checks and review.

Sequence Diagram(s)

sequenceDiagram
  participant Provider
  participant retryObserver
  participant DeepChatLoopRunner
  participant ChatStream
  Provider->>retryObserver: Schedule retry after provider failure
  retryObserver->>DeepChatLoopRunner: retry_scheduled
  DeepChatLoopRunner->>ChatStream: Emit ephemeral waiting block
  Provider->>retryObserver: Start or finish retry
  retryObserver->>DeepChatLoopRunner: retry_started or retry_finished
  DeepChatLoopRunner->>ChatStream: Clear waiting block
Loading

Suggested reviewers: yyhhyyyyyy

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The changes address the silent waiting symptom in issue #2221 by showing retry status and clearing it on retry progress, cancellation, abort, and run exit. The issue also requests the ability to stop … Add or verify explicit stop and resume controls for a request stuck during provider retry, or update the linked issue scope if this PR intentionally addresses only retry-status feedback.
✅ Passed checks (4 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 main change: fixing provider retry waiting feedback.
Out of Scope Changes check ✅ Passed The runtime changes and regression tests remain within the stated provider retry feedback scope. No unrelated code changes are described.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
Full details: Linked Issues check

Explanation

The changes address the silent waiting symptom in issue #2221 by showing retry status and clearing it on retry progress, cancellation, abort, and run exit. The issue also requests the ability to stop or resume execution, but this PR does not add or modify those controls.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files. (1 skipped: 1 too large.)

  • Fix all pre-merge checks with AI
✨ 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 fix/issue-2221-provider-retry-waiting

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.

@zhangmo8
zhangmo8 requested review from yyhhyyyyyy and zerob13 and removed request for yyhhyyyyyy August 31, 2026 05:41

@zerob13 zerob13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review summary

Request changes — the targeted tests pass, but the retry status lifecycle still emits an unnecessary clear between consecutive retries.

P2 — Avoid clearing the retry indicator between retries

  • Location: src/main/agent/deepchat/runtime/deepChatLoopRunner.ts:2075-2086
  • When a retry attempt finishes with retryDecision: retry_scheduled, contextCoordinator emits retry_finished and then immediately emits the next retry_scheduled event. The new observer clears the ephemeral rate-limit snapshot on every retry_finished, then publishes it again for the next schedule.
  • This produces an empty snapshot and a visible status flicker during multi-retry runs, even though the run remains in the same waiting state. It also makes the UI briefly lose the estimated wait state between retries.
  • Please only clear on a terminal retry outcome, or otherwise keep the indicator continuous when retry_finished is followed by another retry_scheduled. Add a regression assertion covering two consecutive transient retries and the abort path.

Verification

  • pnpm exec vitest run --config vitest.config.ts test/main/agent/deepchat/harness/deepChatAgentHarness.test.ts test/main/agent/deepchat/loop/contextCoordinator.test.ts
  • Result: 482 tests passed
  • git diff --check
  • Result: clean

No other merge-blocking issue was identified in this pass.

Avoid clearing the temporary retry status between consecutive provider retries and cover cancellation during the retry wait.
@zhangmo8

Copy link
Copy Markdown
Collaborator Author

Thanks for catching this. Fixed in bb6ab0978.

retry_finished now clears the ephemeral retry status only when `retryDecision !== 'retry_scheduled', so consecutive retries keep the status continuous without an extra empty update. I also added regression coverage for two consecutive transient retries and cancellation during the retry wait.

The targeted regression tests pass (2/2), and the touched files have no diagnostics; git diff --check is clean. Please take another look.

@zerob13 zerob13 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review summary

Approve — the previous blocking finding is resolved.

Re-review scope

Reviewed the incremental changes from 992ecc292 to dac59bb539e892dac818926fc5d8d33b56656d00.

  • retry_finished now clears the ephemeral retry status only for terminal outcomes; consecutive retry_scheduled transitions keep the status continuous.
  • Added focused regression coverage for consecutive transient retries and cancellation during the retry wait.
  • No over-engineering or unexplained breaking change found. The lifecycle handling matches the existing retry_scheduledretry_started → terminal retry_finished flow.
  • Test additions are targeted and proportionate.

Verification

  • Focused Vitest: 483 tests passed
  • oxfmt --check: clean
  • git diff --check: clean
  • PR checks: all required checks passed

Review status: APPROVED

@zhangmo8
zhangmo8 merged commit d42106e into dev Aug 31, 2026
12 checks passed
@zhangmo8
zhangmo8 deleted the fix/issue-2221-provider-retry-waiting branch August 31, 2026 09:23
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] 模型工作到一半突然停止工作,无法强制停止或自行继续

2 participants