Skip to content

feat: Implement changeset state caching and management in AgentHost#318096

Merged
DonJayamanne merged 5 commits into
mainfrom
don/literary-shark
May 25, 2026
Merged

feat: Implement changeset state caching and management in AgentHost#318096
DonJayamanne merged 5 commits into
mainfrom
don/literary-shark

Conversation

@DonJayamanne
Copy link
Copy Markdown
Contributor

@DonJayamanne DonJayamanne commented May 23, 2026

Problem today

  • we have 1000 sessions
  • listSessions will build the state for the session
  • We load the changeset, but only count number of changes +added -deleted
  • However we also load and store the state of changesets for each session in memory
  • However since none of the sessions have been opened (not subscribed), this changeset information for all 1000 sessions is a waste of resources, ideally we should load this into state as and when required (when a session is opened)

Fix

  • we have 1000 sessions
  • listSessions will build the state for the session
  • We load the changeset, but only count number of changes +added -deleted
  • No more loading changesets into memory unless its requested

Copilot AI review requested due to automatic review settings May 23, 2026 11:15
@DonJayamanne DonJayamanne self-assigned this May 23, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors expanded changeset state retention out of AgentHostStateManager into a dedicated AgentHostChangesetStateCache with a soft LRU policy, and reshapes persisted-changeset handling so the session list overlay parses metadata without forcing live state to be seeded for every row.

Changes:

  • Adds AgentHostChangesetStateCache (silent LRU, soft limit 500) and routes all changeset state access in AgentHostStateManager through it.
  • AgentService supplies subscriber/compute-aware canEvict and calls onChangesetLivenessChanged on unsubscribe; AgentHostChangesetService tracks _activeStaticComputes and pings liveness on completion/failure.
  • Splits restorePersistedStaticChangesets into parsePersistedStaticChangesets + applyPersistedStaticChangesets; ChangesetSessionCoordinator.decorateListEntry now only parses (does not seed) for the list overlay.
Show a summary per file
File Description
src/vs/platform/agentHost/node/agentHostChangesetStateCache.ts New LRU-style soft-limit cache with canEvict hook and silent eviction.
src/vs/platform/agentHost/node/agentHostStateManager.ts Delegates changeset state storage to the cache; adds onChangesetLivenessChanged and constructor options.
src/vs/platform/agentHost/node/agentHostChangesetService.ts Adds parse/apply split, isStaticChangesetComputeActive, and active-compute tracking around _doComputeStaticChangeset.
src/vs/platform/agentHost/node/agentHostChangesetCoordinator.ts List overlay now calls parsePersistedStaticChangesets instead of restore (no state seeding).
src/vs/platform/agentHost/node/agentService.ts Wires canEvict to subscriber/subagent/active-compute checks; notifies liveness on unsubscribe.
src/vs/platform/agentHost/test/node/agentHostChangesetService.test.ts Adds parse/apply and LRU eviction test coverage.
src/vs/platform/agentHost/test/node/agentSideEffects.test.ts Updates FakeChangesetService with new no-op methods.

Copilot's findings

  • Files reviewed: 7/7 changed files
  • Comments generated: 1

Comment thread src/vs/platform/agentHost/node/agentHostChangesetCoordinator.ts
@DonJayamanne DonJayamanne marked this pull request as ready for review May 25, 2026 04:22
@DonJayamanne DonJayamanne enabled auto-merge (squash) May 25, 2026 04:23
@DonJayamanne DonJayamanne merged commit dfe5c85 into main May 25, 2026
39 of 40 checks passed
@DonJayamanne DonJayamanne deleted the don/literary-shark branch May 25, 2026 06:27
@vs-code-engineering vs-code-engineering Bot added this to the 1.123.0 milestone May 25, 2026
dileepyavan pushed a commit that referenced this pull request May 27, 2026
…318096)

* feat: Implement changeset state caching and management in AgentHost

* Fixes

* fix: Update restoreSessionIfChangesetSubscription to return void and clarify handling of non-changeset URIs

* refactor: Simplify changeset eviction logic and improve comments for clarity

* feat: Add releaseBranchChanges method and enhance session summary change notifications
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