Skip to content

sessions: Skip local cache entries poisoned by downgrade - #340154

Merged
roblourens merged 2 commits into
mainfrom
roblou/agents/agent-host-downgrade-cache-fix
Oct 6, 2026
Merged

roblourens merged 2 commits into
mainfrom
roblou/agents/agent-host-downgrade-cache-fix

Conversation

@roblourens

@roblourens roblourens commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Summary

Ignore local startup-cache records whose native ahp-session URI scheme was incorrectly persisted as their agent provider by an older VS Code version.

After a downgrade, these records create adapters routed to the unregistered agent-host-ahp-session frontend type. Upgrading does not fix an already-created adapter when the host subsequently advertises the correct provider.

Reject only the known poisoned combination before adapter construction, retain healthy cached records, and rebuild the skipped sessions from authoritative host metadata. Mark the cache dirty so normal saving removes the invalid records. The cache generation and backend session identities remain unchanged.

The rejection is local-provider-only; remote and cloud cache behavior is preserved. This does not make older versions support native session URIs or repair previously saved references to incorrectly routed open panes.

Validation

  • npm run typecheck-client — passed after correcting the test storage variables to use the generic IStorageService contract.
  • npm run build-fast -- --client-only — passed.
  • npm run build-fast — passed, including the extension outputs needed for live validation.
  • ./scripts/test.sh --run src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts --run src/vs/sessions/contrib/providers/remoteAgentHost/test/browser/remoteAgentHostSessionsProvider.test.ts --grep 'cache|cached|opaque advertised|mixed resources' — passed, 45 tests.
  • npm run eslint -- src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts src/vs/sessions/contrib/providers/agentHost/browser/localAgentHostSessionsProvider.ts src/vs/sessions/contrib/providers/remoteAgentHost/browser/cloudSandboxSessionsProvider.ts src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts — passed.
  • git diff --check — passed.

Five new regressions cover selective filtering, removal of an entirely poisoned cache while the host is unavailable, and authoritative Copilot/Claude/Codex reconstruction with fresh-provider restart. The first four regressions were run before the implementation and failed.

Live validation

Passed in a real Code OSS 1.142.0 Dev Agents window on macOS, using isolated copies of two actual poisoned cache records, their host databases and Copilot SDK sessions, plus a healthy legacy-session control.

  • First startup logged exactly two rejected cache entries.
  • Both affected conversations opened with the correct agent-host-copilotcli frontend identity and rendered request/response history.
  • The healthy legacy conversation also opened successfully.
  • The saved cache retained the native backend URIs and corrected their provider to copilotcli.
  • After a full application quit and restart using the same isolated profile, all three conversations opened and rendered again. No poisoned-cache rejection warnings appeared on restart.
  • The original profile cache remained unchanged, and no prompts were submitted.

Live evidence was retained locally as screenshots, sampled video and Playwright traces. Previously saved malformed open-pane references were excluded from the fresh validation profile and remain outside this fix's scope. The CI follow-up changes only TypeScript annotations in the tests; production code and live-validation inputs remain unchanged.

(Written by Copilot)

Reject startup-cache entries that mistook native session URI schemes for agent providers. Rebuild only those local sessions from authoritative host metadata while preserving healthy cache entries and backend identities. Cover filtering, persistence and provider restart.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 6, 2026 21:58
@github-actions

github-actions Bot commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 1d25d5df Current: 5449b694

Changed (1)

sessions/chatCompositeBar/MixedStatuses/Light
Before After
before after

Copilot AI left a comment

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.

Copilot review overview

🟢 Approval recommended

The narrowly scoped fix preserves healthy and remote caches and is covered by focused regression tests.

Review effort: Balanced
Findings: None

What changed in this PR

Filters downgrade-poisoned local session-cache entries so authoritative host metadata can rebuild them correctly.

Changes:

  • Adds provider-specific cache rejection support.
  • Rejects only local ahp-session/ahp-session records and marks the cache dirty.
  • Adds five regression scenarios covering filtering, cleanup, and reconstruction.
File Description
baseAgentHostSessionsProvider.ts Supports rejecting cached metadata.
localAgentHostSessionsProvider.ts Filters poisoned local records.
cloudSandboxSessionsProvider.ts Handles the optional cache-adoption result.
localAgentHostSessionsProvider.test.ts Tests filtering and authoritative reconstruction.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Use the IStorageService contract for generic cached-object reads in the new downgrade regression tests. Verified full client type checking, targeted lint, and all 45 cache tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@roblourens
roblourens marked this pull request as ready for review October 6, 2026 22:35
@roblourens
roblourens enabled auto-merge (squash) October 6, 2026 22:35
@roblourens
roblourens merged commit 011dbac into main Oct 6, 2026
35 checks passed
@roblourens
roblourens deleted the roblou/agents/agent-host-downgrade-cache-fix branch October 6, 2026 23:40
@vs-code-engineering vs-code-engineering Bot added this to the 1.142.0 milestone Oct 6, 2026
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