Repository navigation
chat: reduce full scans on sandbox feed renewal - #345063
Merged
Osvaldo Ortega (osortega) merged 1 commit intoOct 29, 2026
Merged
Osvaldo Ortega (osortega) merged 1 commit into
Osvaldo Ortega (osortega) merged 1 commit into
Conversation
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]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the cloud sandbox discovery and telemetry changes.
No open issues 🎉
What changed in this PR
This PR reduces expensive cloud sandbox inventory scans in the shared discovery flow used by the Editor and Agents Window. Seamless feed renewal uses incremental catch-up, while connection gaps and periodic reconciliation retain full scans.
Changes:
- Distinguishes renewal, reconnect, and task-change refreshes while preserving targeted hints and queued full-refresh precedence.
- Adds per-attempt
cloudSandboxDiscoverytelemetry for discovery mode, cost, and outcome. - Adds regression coverage for feed renewal, refresh coalescing, and telemetry.
No actionable findings remain. Reported validation includes 885 passing tests; live-service load reduction and full integration/smoke flows were not exercised.
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/test/browser/remoteAgentHost/cloudSandboxTelemetry.test.ts |
Tests field classifications and bounded telemetry categories. |
src/vs/workbench/contrib/chat/test/browser/remoteAgentHost/cloudSandboxSessionFeed.test.ts |
Covers seamless renewal, connection gaps, and retained task hints. |
src/vs/workbench/contrib/chat/test/browser/remoteAgentHost/cloudSandboxApiService.test.ts |
Tests per-attempt discovery metrics and outcomes. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/editorCloudSandboxContribution.ts |
Attributes Editor startup discovery. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxTelemetry.ts |
Defines and emits classified discovery telemetry. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionFeed.ts |
Distinguishes refresh reasons and preserves coalesced hints. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxSessionContribution.ts |
Routes refresh reasons and preserves queued discovery intent. |
src/vs/workbench/contrib/chat/browser/remoteAgentHost/cloudSandboxApiService.ts |
Records discovery modes, counters, outcomes, and checkpoint advancement. |
src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/cloudSandboxAgentHostContribution.test.ts |
Covers incremental renewal and full-scan precedence. |
src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxAgentHostContribution.ts |
Attributes Agents Window startup and selection refreshes. |
src/vs/platform/agentHost/common/cloudSandboxAgentHost.ts |
Shares typed discovery options and trigger values. |
Review effort: Balanced
Osvaldo Ortega (osortega)
marked this pull request as ready for review
October 29, 2026 20:39
Osvaldo Ortega (osortega)
enabled auto-merge (squash)
October 29, 2026 22:04
Ross Wollman (rwoll)
approved these changes
Oct 29, 2026
Ben Villalobos (benvillalobos)
approved these changes
Oct 29, 2026
Osvaldo Ortega (osortega)
deleted the
osortega/agents/incremental-sandbox-feed-renewal
branch
October 29, 2026 23:27
Osvaldo Ortega (osortega)
added a commit
that referenced
this pull request
Oct 30, 2026
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)
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.
Summary
Routine renewal of the cloud session-update connection currently requests a full task inventory scan even when the old connection remains available until its replacement is ready. This can repeatedly trigger expensive paginated reads.
cloudSandboxDiscoverytelemetry and focused regression coverage across the shared feed, API, and Agents Window provider.Polling intervals, initial/manual full scans, uncapped pagination, and sandbox-identification rules remain unchanged. This does not revert the completeness fixes in #341823. Entries unavailable through incremental discovery still rely on a subsequent periodic/manual full scan.
Telemetry
cloudSandboxDiscoveryreports the trigger, requested/actual mode, outcome, elapsed time, parsed page count, list HTTP attempts, unique returned tasks, returned sandbox tasks, sandbox summaries absent from or different from the starting cache, and checkpoint advancement.The event emits once per API discovery attempt, including partial, failed, and cancelled attempts. It uses existing telemetry consent controls and adds no task IDs, task content, repository names, URLs, or cursors. Every number and boolean is classified as a measurement. Page counts are not unique backend pages; changed summaries are a local-cache comparison, not an authoritative server change count. List-attempt counts include issued requests subsequently cancelled, unlike the existing aggregated outcome counter.
Related changes
Validation
Successful validation from this implementation was reused for PR creation:
npm run build-fast -- --client-only— passed, including the final incremental output refresh.npm run typecheck-client— passed.git diff --name-only --diff-filter=ACM -z -- '*.ts' | xargs -0 npm run eslint --— passed for all 11 changed files before committing; the final comment-only changes also passed targeted lint.git diff --check— passed.A scoped telemetry-extractor check also verified the exact event fields, owner, and all measurement classifications. The initial Electron runner could not dynamically load the API test module; the Chrome runner subsequently executed all five suites successfully. Live-service load reduction and full integration/smoke flows were not exercised.
How to test
cloudSandboxDiscoveryevents to compare renewal-triggered scan modes, page/attempt counts, and outcomes after rollout.