Skip to content

fix(vscode): deduplicate fatal autocomplete notification for next-edit provider#11569

Open
markijbema wants to merge 5 commits into
mainfrom
fix/next-edit-fatal-notification-dedup
Open

fix(vscode): deduplicate fatal autocomplete notification for next-edit provider#11569
markijbema wants to merge 5 commits into
mainfrom
fix/next-edit-fatal-notification-dedup

Conversation

@markijbema

@markijbema markijbema commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

What

Fixes the bug where the "Kilo Code autocomplete has been paused" notification fires on every keystroke when the Inception next-edit provider is configured and the user is not logged in. Brings the next-edit provider to full parity with the classic FIM pause/recover behavior.

Why

NextEditInlineCompletionProvider.handleError() had no circuit breaker: every 401/402 response fired onFatalError, popping the toast again. The classic FIM path already handles this correctly via ErrorBackoff + a fatalNotified guard + a 402 balance probe.

Changes

NextEditInlineCompletionProvider:

  • Adds an ErrorBackoff instance and a fatalNotified flag.
  • provideInlineCompletionItems returns [] immediately when backoff.blocked() (no network request). When blocked on a 402, it periodically probes the balance endpoint (hasBalance()) and resumes if the user topped up — matching FIM's self-heal.
  • On a successful (non-throwing) Mercury response, calls backoff.success() and clears fatalNotified, so each fatal episode notifies exactly once.
  • handleError calls backoff.failure(err) and only invokes onFatalError once per fatal episode.
  • New resetBackoff() clears both backoff and fatalNotified.

AutocompleteServiceManager:

  • Calls nextEditProvider.resetBackoff() alongside inlineCompletionProvider.resetBackoff() in both the onStateChange and global.disposed handlers, so a re-auth or reconnect (e.g. login) unblocks the next-edit path too.

Behavior after this change (consistent with FIM)

  • Not logged in (401): pauses after the first failure, notifies once, and resumes when the user logs in (the CLI emits global.disposed / a connection state change, which resets the backoff).
  • Credits depleted (402): pauses, notifies once, and self-heals every ~5 min via a lightweight balance check — no login/reconnect required.
  • Rate limit / 5xx: exponential backoff with a circuit breaker, no toast.

…t provider

Mirror the FIM path's pause/notify semantics in NextEditInlineCompletionProvider:
- Add ErrorBackoff instance and fatalNotified flag to gate repeated notifications
- Block all requests once a fatal (401/402) is recorded via backoff.blocked()
- Only call onFatalError once per fatal episode via fatalNotified guard
- Add resetBackoff() method cleared on auth/connection state changes
- Call nextEditProvider.resetBackoff() alongside classic provider in AutocompleteServiceManager

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
@kilo-code-bot

kilo-code-bot Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • packages/kilo-vscode/src/services/autocomplete/classic-auto-complete/AutocompleteInlineCompletionProvider.ts
  • packages/kilo-vscode/src/services/autocomplete/classic-auto-complete/BackoffGate.ts
  • packages/kilo-vscode/src/services/autocomplete/next-edit/NextEditInlineCompletionProvider.ts
Previous Review Summaries (2 snapshots, latest commit f3ec065)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit f3ec065)

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • .changeset/fix-next-edit-fatal-notification-dedup.md
  • packages/kilo-vscode/src/services/autocomplete/AutocompleteServiceManager.ts
  • packages/kilo-vscode/src/services/autocomplete/next-edit/NextEditInlineCompletionProvider.ts

Previous review (commit 8acd647)

Status: 2 Issues Found | Recommendation: Address before merge

Overview

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

WARNING

File Line Issue
packages/kilo-vscode/src/services/autocomplete/next-edit/NextEditInlineCompletionProvider.ts 73 402 backoff never self-recovers when credits are replenished.
packages/kilo-vscode/src/services/autocomplete/next-edit/NextEditInlineCompletionProvider.ts 364 Retriable failures are never cleared after a later success.

Fix these issues in Kilo Cloud

Files Reviewed (3 files)
  • .changeset/fix-next-edit-fatal-notification-dedup.md - 0 issues
  • packages/kilo-vscode/src/services/autocomplete/AutocompleteServiceManager.ts - 0 issues
  • packages/kilo-vscode/src/services/autocomplete/next-edit/NextEditInlineCompletionProvider.ts - 2 issues

Reviewed by gpt-5.4-20260305 · Input: 94.9K · Output: 7.4K · Cached: 490K

Review guidance: REVIEW.md from base branch main

markijbema and others added 4 commits June 23, 2026 09:19
Bring NextEditInlineCompletionProvider to full parity with the FIM path:
- On a successful (non-throwing) Mercury response, call backoff.success() and
  clear fatalNotified so each fatal episode notifies exactly once.
- When blocked by a 402, periodically probe the balance endpoint (hasBalance)
  and resume autocomplete if the user topped up, instead of waiting for an
  auth/reconnect event.

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
Both the FIM and next-edit providers hand-rolled the same pause/notify/recover
state machine around ErrorBackoff (blocked-gate + 402 balance probe, notify-once
latch, reset-on-success, hasBalance). Extract that orchestration into a single
BackoffGate so the two providers can't drift apart again — the exact divergence
that let next-edit spam the paused notification. No behavior change.

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>

Copy link
Copy Markdown
Contributor Author

Refactored to remove the duplication: the pause/notify/recover state machine that both providers were hand-rolling (blocked-gate + 402 balance probe, notify-once latch, reset-on-success, hasBalance) is now extracted into a single shared BackoffGate (classic-auto-complete/BackoffGate.ts). Both AutocompleteInlineCompletionProvider (FIM) and NextEditInlineCompletionProvider consume it via gate.allow() / gate.success() / gate.failure() / gate.reset(). This is behavior-preserving and stops the two paths from drifting apart again — the original cause of the next-edit notification spam. Net -82/+21 in the providers.

NJ-2020 pushed a commit to NJ-2020/kilocode that referenced this pull request Jul 4, 2026
…hout errors, fix issue with reasoning opaque not being picked up for gemini models (Kilo-Org#11569)
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