Skip to content

feat(retry): add configurable delay and retry limits#4704

Closed
dannycreations wants to merge 6 commits intoKilo-Org:mainfrom
dannycreations:qol-auto-retry
Closed

feat(retry): add configurable delay and retry limits#4704
dannycreations wants to merge 6 commits intoKilo-Org:mainfrom
dannycreations:qol-auto-retry

Conversation

@dannycreations
Copy link
Copy Markdown

@dannycreations dannycreations commented Dec 29, 2025

Implementation

  • Implement retry logic in Task core to respect new configurations
  • Update settings UI with sliders for delay and retry count
  • Add localization for new settings across all supported languages
  • Add unit tests for auto-retry logic

Screenshots

image image

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Dec 29, 2025

🦋 Changeset detected

Latest commit: 389a4ec

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
kilo-code Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@dannycreations dannycreations force-pushed the qol-auto-retry branch 5 times, most recently from 105c827 to 0c7fbe4 Compare January 6, 2026 13:04
@dannycreations dannycreations force-pushed the qol-auto-retry branch 5 times, most recently from 4c06668 to 0c2e8e2 Compare January 13, 2026 01:07
@kevinvandijk
Copy link
Copy Markdown
Contributor

Thanks @dannycreations! Due to the merge from upstream there are some merge conflicts. I will resolve those and review soon.

@dannycreations dannycreations force-pushed the qol-auto-retry branch 2 times, most recently from ccde0ab to 26082b6 Compare January 15, 2026 09:21
@dannycreations
Copy link
Copy Markdown
Author

@kevinvandijk done pushing new code already tested all working

@dannycreations dannycreations changed the title feat(auto-retry): add configurable max retries and backoff strategy feat(retry): implement configurable max retries and backoff strategy Jan 16, 2026
Comment thread webview-ui/src/i18n/locales/en/kilocode.json Outdated
Comment thread cli/src/config/mapper.ts Outdated
Comment thread src/core/task/Task.ts Outdated
Comment thread cli/src/host/ExtensionHost.ts Outdated
@dannycreations dannycreations changed the title feat(retry): implement configurable max retries and backoff strategy feat(retry): add configurable delay and retry limits Jan 17, 2026
@dannycreations
Copy link
Copy Markdown
Author

@marius-kilocode done implement every problem, im also remove all strategy to be "constant" by default since user can now change the retry delay, im also not touch any cli things and it should be fallback to default

- Add `alwaysApproveResubmit`, `requestDelaySeconds`, and `requestRetryMax` to global settings and state.
- Update `Task` logic to respect maximum retry limits and use configurable delays instead of hardcoded exponential backoff.
- Integrate retry configuration sliders and toggles into the Auto-Approve settings UI.
- Add comprehensive unit tests for auto-retry logic, delay calculations, and state constraints.
- Update localization files for all supported languages with new retry-related labels and descriptions.
Comment thread webview-ui/src/components/settings/AutoApproveSettings.tsx Outdated
Comment thread webview-ui/src/i18n/locales/en/settings.json Outdated
Comment thread webview-ui/src/components/settings/SettingsView.tsx Outdated
Comment thread packages/types/src/global-settings.ts Outdated
@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented Feb 20, 2026

Code Review Summary

Status: 6 Issues Found (from prior reviews) | Recommendation: Address before merge

Fix these issues in Kilo Cloud

Overview

Severity Count
CRITICAL 1
WARNING 5
SUGGESTION 0
Issue Details (click to expand)

CRITICAL

File Line Issue
src/core/task/Task.ts 3604 retryMax check only gates the backoff delay, NOT the actual retry. Lines 3619–3627 (stack.push + continue) execute unconditionally, so mid-stream retries are unlimited regardless of requestRetryMax. The retry push should be inside the if block, or an else branch should handle the max-exceeded case (e.g., throw or break).

WARNING

File Line Issue
src/core/task/Task.ts 4880 retryAttempt parameter is unused in backoffAndAnnounce — the exponential backoff was replaced with a constant delay but the parameter was not removed.
src/core/task/__tests__/auto-retry.spec.ts 78 Test "should calculate correct delay" has no assertions and doesn't await the backoffAndAnnounce call — it's effectively a no-op test.
src/core/task/__tests__/auto-retry.spec.ts 90 Tests re-implement the retry logic locally with a shouldRetry function instead of testing the actual Task class methods. These tests verify the local function, not the production code.
webview-ui/src/components/settings/AutoApproveSettings.tsx 393 Indentation mismatch — lines 330 and 393 use spaces instead of tabs, inconsistent with the project's Prettier config (useTabs: true).
src/core/task/Task.ts 4925 Stale comment says "Show countdown timer with exponential backoff" but the backoff is now constant (uses requestDelaySeconds directly).
Other Observations (not in diff)

No additional issues found outside the diff.

Files Reviewed (30 files)
  • .changeset/six-guests-admire.md - 0 issues
  • packages/types/src/global-settings.ts - 0 issues
  • packages/types/src/vscode-extension-host.ts - 0 issues
  • src/core/auto-approval/index.ts - 0 issues
  • src/core/task/Task.ts - 3 issues
  • src/core/task/__tests__/auto-retry.spec.ts - 2 issues
  • src/core/webview/ClineProvider.ts - 0 issues
  • src/core/webview/webviewMessageHandler.ts - 0 issues
  • webview-ui/src/components/settings/AutoApproveSettings.tsx - 1 issue
  • webview-ui/src/components/settings/AutoApproveToggle.tsx - 0 issues
  • webview-ui/src/components/settings/SettingsView.tsx - 0 issues
  • webview-ui/src/components/settings/__tests__/AutoApproveToggle.spec.tsx - 0 issues
  • webview-ui/src/context/ExtensionStateContext.tsx - 0 issues
  • webview-ui/src/hooks/useAutoApprovalToggles.ts - 0 issues
  • webview-ui/src/i18n/locales/ar/settings.json - 0 issues
  • webview-ui/src/i18n/locales/ca/settings.json - 0 issues
  • webview-ui/src/i18n/locales/cs/settings.json - 0 issues
  • webview-ui/src/i18n/locales/de/settings.json - 0 issues
  • webview-ui/src/i18n/locales/en/settings.json - 0 issues
  • webview-ui/src/i18n/locales/es/settings.json - 0 issues
  • webview-ui/src/i18n/locales/fr/settings.json - 0 issues
  • webview-ui/src/i18n/locales/hi/settings.json - 0 issues
  • webview-ui/src/i18n/locales/id/settings.json - 0 issues
  • webview-ui/src/i18n/locales/it/settings.json - 0 issues
  • webview-ui/src/i18n/locales/ja/settings.json - 0 issues
  • webview-ui/src/i18n/locales/ko/settings.json - 0 issues
  • webview-ui/src/i18n/locales/nl/settings.json - 0 issues
  • webview-ui/src/i18n/locales/pl/settings.json - 0 issues
  • webview-ui/src/i18n/locales/pt-BR/settings.json - 0 issues
  • webview-ui/src/i18n/locales/ru/settings.json - 0 issues

dannycreations and others added 4 commits February 20, 2026 12:54
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
startTask: false,
})

const delay = (task as any).backoffAndAnnounce(1, new Error("test"))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: Test has no assertions — this test calls backoffAndAnnounce but never awaits the result and contains zero expect() calls. It will always pass regardless of actual behavior.

The comment on line 79 acknowledges this limitation. Consider either:

  1. Properly mocking delay and awaiting the result to verify the delay value
  2. Removing this test until it can be made meaningful (a test with no assertions gives false confidence in coverage)

requestRetryMax: 2
}

const shouldRetry = (attempt: number) =>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: Tests re-implement retry logic locally instead of testing the actual Task class — the shouldRetry function defined here duplicates the condition from Task.ts rather than exercising the real code path. If the logic in Task.ts diverges from this local copy, these tests will still pass while the actual behavior is broken.

Consider testing the real Task methods (e.g., verifying that attemptApiRequest or the streaming loop actually stops retrying when requestRetryMax is exceeded) rather than testing a standalone reimplementation of the condition.

Comment thread src/core/task/Task.ts
stateForBackoff?.autoApprovalEnabled &&
stateForBackoff?.alwaysApproveResubmit && // kilocode_change
(retryMax === 0 || (currentItem.retryAttempt ?? 0) < retryMax)
) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

CRITICAL: The retryMax check here only gates the backoff delay — it does NOT gate the actual retry. Lines 3619–3627 (stack.push + continue) execute unconditionally outside this if block, meaning when retryMax is reached, the backoff is skipped but the retry still happens. This creates an infinite retry loop without any delay.

The stack.push + continue block should be moved inside this if, with an else branch that either breaks or prompts the user (similar to the empty-assistant-response path at line 3965 which correctly uses if/else).

Comment thread src/core/task/Task.ts

// Shared exponential backoff for retries (first-chunk and mid-stream)
// Shared backoff for retries (first-chunk and mid-stream)
private async backoffAndAnnounce(retryAttempt: number, error: any): Promise<void> {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: The retryAttempt parameter is now unused in this method body. It was previously used for the exponential backoff calculation (Math.pow(2, retryAttempt)), but since the delay is now constant, nothing references it. Consider removing it to avoid confusion.

Also, the comment on line 4925 ("Show countdown timer with exponential backoff") and the error message on line 4938 ("Exponential backoff failed") are stale — the method no longer uses exponential backoff.

const delay = (task as any).backoffAndAnnounce(1, new Error("test"))
// We can't easily await this because it has a loop with delay()
// but we can check the internal logic if we expose it or mock delay better
})
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

WARNING: No-op test — this test creates a Task and calls backoffAndAnnounce but never awaits the returned promise and has no assertions. The comment acknowledges this limitation but the test still passes vacuously, giving false confidence in coverage.

Consider either:

  • Awaiting the promise and asserting on the mocked delay calls
  • Removing this test until it can be properly implemented
  • At minimum, adding await and an assertion on the mock

Comment thread webview-ui/src/components/settings/AutoApproveSettings.tsx Outdated
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
@dannycreations dannycreations deleted the qol-auto-retry branch February 20, 2026 06:51
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