Repository navigation
chat: back off short-lived session feed connections - #345061
Merged
Dmitriy Vasyura (dmitrivMS) merged 1 commit intoOct 30, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the session-feed reconnect backoff change.
No open issues 🎉
What changed in this PR
This PR reduces repeated session-feed reconnects after short-lived connections, while preserving credential renewal and discovery polling fallback. It is separate from the server-relative renewal change in #345060.
Changes:
- Adds exponential reconnect backoff with jitter and a 60-second cap, resetting only after 60 seconds continuously connected.
- Reuses the shared delay helper with a narrower policy parameter type.
- Adds fake-time regression tests and documents the reconnect behavior.
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/test/browser/remoteAgentHost/cloudSandboxSessionFeed.test.ts |
Tests delay growth, healthy-connection reset, and bounded negotiations during repeated disconnects. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionFeed.ts |
Applies reconnect backoff and owns the healthy-connection timer in the socket’s disposable store. |
src/vs/platform/github/README.md |
Documents session-feed backoff and failed-negotiation behavior. |
src/vs/platform/agentHost/common/reconnectPolicy.ts |
Narrows the helper’s policy parameter to the fields it reads without changing delay calculations. |
Review effort: Balanced
Dmitriy Vasyura (dmitrivMS)
marked this pull request as ready for review
October 29, 2026 23:41
Ross Wollman (rwoll)
previously approved these changes
Oct 29, 2026
Reuse the reconnect-delay helper for jittered exponential delays capped at one minute. Reset backoff only after a minute of continuous connection, while retaining the existing stop-after-negotiation-failure behavior. Co-authored-by: Copilot <[email protected]>
Dmitriy Vasyura (dmitrivMS)
force-pushed
the
dev/dmitriv/cloud-feed-reconnect-backoff
branch
from
October 29, 2026 23:51
06fe48d to
0b8b792
Compare
Benjamin Christopher Simmonds (benibenj)
approved these changes
Oct 29, 2026
Dmitriy Vasyura (dmitrivMS)
deleted the
dev/dmitriv/cloud-feed-reconnect-backoff
branch
October 30, 2026 00:15
Osvaldo Ortega (osortega)
pushed a commit
that referenced
this pull request
Oct 30, 2026
Reuse the reconnect-delay helper for jittered exponential delays capped at one minute. Reset backoff only after a minute of continuous connection, while retaining the existing stop-after-negotiation-failure behavior. Co-authored-by: Copilot <[email protected]> (cherry picked from commit dc9e435)
Osvaldo Ortega (osortega)
added a commit
that referenced
this pull request
Oct 30, 2026
…ist (#345268) * chat: reduce full scans on sandbox feed renewal (#345063) Use incremental inventory catch-up after seamless feed renewal while retaining full recovery for connection gaps and periodic reconciliation. Preserve queued refresh intent and report bounded per-scan cost and outcome telemetry. Co-authored-by: Copilot <[email protected]> (cherry picked from commit a06ebdc) * chat: back off short-lived session feed connections (#345061) Reuse the reconnect-delay helper for jittered exponential delays capped at one minute. Reset backoff only after a minute of continuous connection, while retaining the existing stop-after-negotiation-failure behavior. Co-authored-by: Copilot <[email protected]> (cherry picked from commit dc9e435) * chat: use server-relative session feed renewal (#345060) * chat: use server-relative session feed renewal Prefer the service's relative renewal and expiry durations to avoid rapid reconnects caused by client clock skew. Preserve timestamp-only compatibility, validate timing bounds, and cover the shared-client and IPC paths. Co-authored-by: Copilot <[email protected]> * test: give feed metadata cases stable names Use explicit case labels instead of payload-derived titles so duration cases remain unique and timestamp-based fixtures have stable names across CI reruns. Co-authored-by: Copilot <[email protected]> * chat: include feed negotiation time in renewal delay Start monotonic timing before awaiting feed negotiation so response delivery and account rechecks count toward renewal. Add an injected stopwatch for deterministic coverage of delayed negotiation and WebSocket setup. Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> (cherry picked from commit f327482) * chat: reduce cloud sandbox discovery load on the task list (#345216) * chat: follow task-list pagination links during sandbox discovery Discovery synthesized page=N for the next request and only checked that a Link header mentioned rel=next, so it could not follow continuation URLs and would re-request the same page indefinitely if the server stopped honoring page numbers. Follow the advertised next link instead, adopting only its query so requests stay on the CORS-enabled endpoint and keep the scope filters a numbered link may omit. A repeated or unparseable continuation fails the scope rather than looping or silently completing a truncated scan. Co-authored-by: Copilot <[email protected]> * chat: poll sandbox discovery every five minutes with jitter Discovery polled the task list every minute whenever the session feed was not connected, which multiplied list requests across windows and lined them up on the same minute grid. Poll on one five-minute interval regardless of feed state, spread each automatic poll with up to a minute of jitter measured from the latest inventory pass, and raise the failure backoff ceiling so unsuccessful scans still slow down. Focus and host-selection refreshes keep bypassing the timer when discovery is stale. Co-authored-by: Copilot <[email protected]> * chat: slow sandbox discovery polling for accounts without sandboxes An account with no known sandbox gains nothing from incremental polls between full reconciliations, so poll it only at the full-scan interval until a sandbox appears through discovery, provisioning, or the session feed. Re-arm the poll timer when an inventory pass settles so a changed interval, from backoff or an idle inventory, takes effect on the next tick instead of one interval late. Co-authored-by: Copilot <[email protected]> * chat: stop polling sandbox discovery while the session feed is connected A connected feed already pushes task changes, and its renewals and reconnects catch up the inventory, so the timer-driven poll only duplicated those reads. Skip it while the feed is connected; the timer keeps ticking so polling resumes within one interval once the feed drops. Focus and host-selection refreshes are unchanged. Co-authored-by: Copilot <[email protected]> * chat: re-arm the sandbox discovery poll when the first sandbox arrives Only inventory scans re-armed the poll timer, so an account whose first sandbox arrived through local provisioning or a feed task read kept the idle fifteen-minute timer until it fired. Re-arm from the shared environment registration on the empty-to-populated transition, without counting it as an inventory pass. Co-authored-by: Copilot <[email protected]> * chat: retry failed session feed negotiations with a slow backoff A window whose first session feed negotiation failed for any reason other than the feed being unavailable for the account, for example a transient HTTP 503, stopped trying for the rest of its lifetime and fell back to discovery polling until the next reload or setting toggle. A failed renewal or reconnect did the same. The feed is the cheapest way for the service to keep a window current, so every window stuck this way was one more window on the polling path. Only an unavailable feed (the service declining it for the account) or an invalid feed message still stop attempts. Every other failed negotiation or handshake is retried on a jittered exponential backoff that starts at about one minute and caps at thirty minutes, and never sooner than a Retry-After. Dropped sockets keep their faster reconnect backoff; both share one consecutive-failure counter that resets after a healthy connection. The first connection after any gap still requests full reconciliation. Feed transitions are reported through a new cloudSandboxSessionFeed telemetry event with a bounded outcome, the consecutive failure count, the scheduled retry delay, and the rejected negotiation status, so windows left on polling can be told apart from windows receiving push updates. Co-authored-by: Copilot <[email protected]> * chat: keep backing off session feed sockets that repeatedly drop A dropped feed socket reconnected on a 1 s to 60 s jittered backoff and stayed at that ceiling for as long as the socket kept dropping, because the failure counter only resets after a connection survives for a minute. A relay that repeatedly accepts and then closes connections therefore cost every window a negotiation request, a socket connect and a telemetry event up to twice a minute, indefinitely. Share the thirty-minute ceiling of the negotiation retry policy instead: the first six drops still reconnect within seconds, after which each further drop keeps doubling the delay (about one, two, four, eight and seventeen minutes, then thirty) until a connection stays healthy for a minute. The dropped-socket test now drives the schedule past the old ceiling with immediately closing sockets, and the flapping bound reflects the lower rate. Co-authored-by: Copilot <[email protected]> * chat: assert which trigger refreshes stale sandbox discovery The stale focus and host selection test waited exactly one poll interval before selecting the host, so the automatic poll fired at the same instant and performed the refresh; the selection found a scan in flight and did nothing. The assertion held, but for the wrong trigger, both before and after the interval change. Give the poll a jitter in this test so that it is due after the inventory goes stale, and record the trigger of every scan so the final refresh is proven to come from the host selection. Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> (cherry picked from commit b7eceff) --------- Co-authored-by: Osvaldo Ortega <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Dmitriy Vasyura <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Back off session-feed reconnects when sockets repeatedly complete their handshake but close shortly afterward.
computeReconnectDelayfor exponential delays with a one-second base, a 60-second cap, and upper-half jitter.The shared delay helper now accepts only the policy fields it actually reads; existing remote-agent-host callers and delay calculations are unchanged.