Repository navigation
agentHost: make agent-host.db authoritative for session state (Block 3a) - #341626
Merged
Sandeep Somavarapu (sandy081) merged 89 commits intoOct 15, 2026
Merged
Conversation
Dmitriy Vasyura (dmitrivMS)
previously approved these changes
Oct 14, 2026
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
One or more issues must be addressed before approval.
3 open findings
What changed in this PR
Separates session-wide state from chat-owned data to support future chat moves while preserving downgrade compatibility.
Changes:
- Routes session metadata through central state and compatibility mirrors.
- Passes authoritative settings through chat contexts and redirects chat-row persistence.
- Updates service wiring, tests, and architecture documentation.
| File | Description |
|---|---|
| src/vs/platform/agentHost/test/node/sessionStorageIdentity.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/sessionArtifactRemoval.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/sessionAdditionalWorktrees.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/missionControlSdkEventSource.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/codex/codexModelRefresh.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/codex/codexChatDiscovery.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/codex/codexAgent.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/claudeAgent.integrationTest.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/chatMetadataTestHelpers.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentSessionRegistry.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentServiceTestUtils.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostUtilityModelService.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostTurnTelemetry.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostTurnHangTelemetry.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostToolCallTelemetry.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostSessionTitleController.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostSeams.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostSavedChatService.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostReviewService.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostReviewService.integrationTest.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostPullRequestOperationProvider.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostPullRequestOperationHandler.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostLocalTurns.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostDatabase.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostCustomizationEnablementService.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostContributions.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostCommitOperationHandler.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostChangesetStrategy.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostChangesetCoordinator.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostCatalogSyncService.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/node/agentHostCatalogReconciliationService.test.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/test/common/sessionTestHelpers.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/shared/sessionAdditionalWorktrees.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/shared/persistSessionMetadata.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/sessionStorageIdentity.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/missionControl/missionControlSdkEventSource.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/compatibleSessionDatabase.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/compatibleAgentHostDatabase.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/chatContributions/worktreeAnnouncement/worktreeAnnouncementContribution.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/chatContributions/sessionWorkspaceConversion/sessionWorkspaceConversionService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/chatContributions/sessionFlags/sessionFlagsContribution.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/chatContributions/persistedFailedTurns/persistedFailedTurnsContribution.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/chatContributions/chatDraft/chatDraftContribution.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/chatContributions/additionalWorktreeLifecycle/additionalWorktreeLifecycleService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentSideEffects.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentSessionRegistry.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentServiceComposition.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostUtilityModelService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostTurnStarter.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostSkillCompletionProvider.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostSessionTitleController.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostServices.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostSavedChatService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostReviewService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostPullRequestOperationProvider.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostLocalTurns.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostGitStateService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostDatabase.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostCustomizationEnablementService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostChatInputService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostChatCatalogV2.md | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostChangesetCoordinator.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostCatalogSourceResolver.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostCatalogReconciliationService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentHostBootstrap.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/node/agentChatContext.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/sessionDataService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/meta/vscode/agentDevContainerWorktreeMeta.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/meta/agentDevContainerWorktreeMeta.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/agentHostCheckpointService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/agentHostChangesetService.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/common/agent.ts | Updated as part of this pull request. |
| src/vs/platform/agentHost/AGENTS.md | Updated as part of this pull request. |
🧠 Review effort: Balanced
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Sandeep Somavarapu (sandy081)
disabled auto-merge
October 14, 2026 21:02
Sandeep Somavarapu (sandy081)
enabled auto-merge (squash)
October 14, 2026 21:51
Sandeep Somavarapu (sandy081)
disabled auto-merge
October 14, 2026 21:55
Aaron Munger (amunger)
previously approved these changes
Oct 14, 2026
Contributor
|
Base:
|
Sandeep Somavarapu (sandy081)
enabled auto-merge (squash)
October 14, 2026 22:25
Sandeep Somavarapu (sandy081)
requested review from
Aaron Munger (amunger) and
Dmitriy Vasyura (dmitrivMS)
October 14, 2026 23:32
Sandeep Somavarapu (sandy081)
disabled auto-merge
October 15, 2026 00:14
Sandeep Somavarapu (sandy081)
enabled auto-merge (squash)
October 15, 2026 03:13
Sandeep Somavarapu (sandy081)
removed request for
Aaron Munger (amunger) and
Dmitriy Vasyura (dmitrivMS)
October 15, 2026 06:11
Test-only fixtures for Block 3a. writeLegacySessionState writes the session.db, peer db and agent-host.db state a 1.142, 1.143 or 2b build leaves for a Copilot session with a default chat and peers in the same and a different folder (drafts, local and failed turns, checkpoint refs, git/gitData, changes, titles, peerChats, storage identities, legacy chat catalog and catalog payload). readOldBuildView reads back exactly what those builds read, so later tests can assert an old build still sees the same state after a newer build writes it. InMemorySessionDataService keeps real in-memory SessionDatabases alive across simulated builds. Co-authored-by: Copilot <[email protected]>
…w filter Block 3a C1. agent-host.db migration 15 adds the session state tables (session_state, session_state_values, session_folder_state, session_branch_changesets, session_chat_state, chat_turn_checkpoints, session_checkpoint_repositories, chat_row_mirror). They are additive; older builds skip the version and never read them. IAgentHostDatabase gains their API (import, CAS write, mirror and row acknowledgements, checkpoint index and sequence, row mirror bases, storage references, garbage), translated to storage spelling by CompatibleAgentHostDatabase. Tombstone, exclusion and both unregistrations delete a session's rows and markers; a provider-absent exclusion keeps them. session.db gets no schema change. setForeignRows records the row owner and the turn ids an older build kept for other chats; turn scans, truncation and the conversation check ignore them (read from the persisted keys in each statement, so every connection agrees), while getAllCheckpointRefs still returns every ref. A fork remap drops them from the copy, and the checkpoint parent fallback skips foreign refs. Co-authored-by: Copilot <[email protected]>
Block 3a C2. IAgentHostSessionStateStore owns session-level values, per-folder git state, branch-changes blobs and legacy-catalog chat summaries, authoritative in agent-host.db. - load imports a session once from the old format older builds keep in session.db (values, git maps, base branch, blobs, chat titles, read flag, directories, changes), lazily and without creating storage. On the first load in a process it reconciles: per entry, a mirror that differs from the recorded merge base was edited by an older build and wins; otherwise central state wins and stale mirrors are rewritten, which also repairs a crash between the two writes. - Writes go to agent-host.db first; their old format is written per entry, coalesced per session (250 ms), and the revision acknowledged only once every entry is mirrored. noteMirrored lets callers that wrote the mirror themselves skip the rewrite. - Operations on a session share one exclusive section keyed by its storage directory; re-entrant calls throw instead of deadlocking. - readWithoutImport and refreshFromMirror serve sweeps and provider writes the host cannot route. The registry in agentHostSessionStateMirror.ts is the frozen key format. The node layer may now import async_hooks for the re-entrancy guard. Co-authored-by: Copilot <[email protected]>
Block 3a C3.1. Readers can keep their old-format parsing while their source becomes central: - legacyMetadata renders what session.db would hold for given keys if every mirror were current, and names the keys the store does not own (provider data, blobs, membership) for callers to read as before. - catalogMetadataReference serves the catalog projection: owned keys centrally, the rest from session.db. - readWithoutImport renders central state for imported sessions that are not loaded and never imports; readValuesWithoutImport serves sweeps over many sessions with one central read. - readSessionStateValues reads any number of sessions in two statements. Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
…rol writers through the session state store Co-authored-by: Copilot <[email protected]>
Worktree isolation, workspace conversion quarantine and CopilotAgent session-level owned keys now use store.writeMetadata with an Immediate mirror. Adds gitState delete test, per-group tests, and hardens fire-and-forget project resolution writes. Co-authored-by: Copilot <[email protected]>
…fixtures Co-authored-by: Copilot <[email protected]>
…e store Whole folder-map writes (agentHost.gitData / agentHost.githubData) now map to per-folder central entries, and the migration writer uses the store with an Immediate mirror. The unowned single-folder key stays deleted until C4 renders it. Co-authored-by: Copilot <[email protected]>
… repair earlier imports
The session state import read the Copilot launch pin (copilot.workingDirectory(ies)) only when the session URI's provider was `copilot`, which is never the case for `copilotcli:` or `ahp-session:` sessions. Sessions without agentHost.sessionWorkingDirectories (most real ones) were imported with no launch folders, so their peers could not resume.
- Resolve launch folders from the chat's own Copilot pin, else the session db's, regardless of the URI scheme.
- Version the launch-directory backfill marker ('2'); sessions imported with the earlier marker get their empty launch folders resolved again on their next load, once.
- The compatibility fixture can omit agentHost.sessionWorkingDirectories, and tests cover copilotcli: and ahp-session: sessions without it.
Co-authored-by: Copilot <[email protected]>
…s on main A cold peer resume compared its folder with central defaultChatWorkingDirectory and had no fallback to the session db's Copilot pin, so a peer without its own pin failed with "missing working directory", and a peer of an archived session resolved as its own workspace: worktree isolation then read the peer's (unset) archived state and tried to recreate the session's deleted worktree. - Fall back to the session db's copilot.workingDirectory, and compare with it when the host supplies no default-chat folder (read lazily). - A peer of an archived session resumes through the session, so it gets the repository root for history and never recreates the worktree. Co-authored-by: Copilot <[email protected]>
…log is normalized The session state store fixed a session's catalog authority when it loaded it. A new session is loaded before its normalized catalog is registered, and a legacy session can be loaded before its catalog is migrated, so the store kept mirroring such a session's chat fields the legacy way: title writes landed as customChatTitle:<defaultChat> in session.db (main writes no such key there). Under slow I/O the coalesced mirror flush lands inside "rename_chat replaces live and persisted default and peer chat titles", which then fails. - IAgentHostSessionStateStore.noteCatalogNormalized: under the session's lock, flushes what was written while the catalog was a legacy one, then reloads the model with the normalized authority and drops its legacy chat mirror entries. - AgentService calls it after a new session's catalog is registered and after a catalog migration. - The rename test drains the store's mirrors before reading session.db, so it fails without the fix at any I/O speed; the sole-default-chat rename test is back to main's expectation. Co-authored-by: Copilot <[email protected]>
An annotation change is written to session.db in the background. When the session was dropped from memory and restored before that write landed, the restore read the previous annotations and the change disappeared from live state (pre-existing on main, intermittent under slow I/O in "annotations survive session state restoration"). A restore now waits for the latest write of the same annotations. Co-authored-by: Copilot <[email protected]>
…added lines as zero in session diffs The file-edit aggregation diffed a created file against empty content, and the line diff counts that content's single empty line, so a new one-line file reported +1 -1, while the file-edit tracker and Git report +1 -0. The session changeset therefore changed counts depending on which computation ran last, and "session changeset aggregates provider edits from default and peer chats" failed whenever a later recompute replaced the one it sampled (pre-existing on main; failing on Windows CI). Co-authored-by: Copilot <[email protected]>
…instead of computing When the live branch diff is unavailable (Git fails or returns nothing in a Git repository), the changeset service keeps the earlier result. Main seeded that result from the stored branch diff blob, so a failed refresh showed the stored files as ready. This build no longer reads those blobs back (decision D3), so after a restart there is no earlier result and the changeset stayed computing forever, logging nothing. With no earlier ready or error result, the failure is now reported as a computeFailed error; a later successful computation replaces it. Co-authored-by: Copilot <[email protected]>
…branch diffs The failed-first-computation test also runs with the branch diff blobs an older build left in session.db (plain, folder-scoped and legacy keys): they are not read back, and the changeset still ends in an error instead of computing. Co-authored-by: Copilot <[email protected]>
…lemetry test Each send follows its chat's asynchronous preparation, and the test gave the three sends a budget of 50 macrotask ticks. On a loaded macOS runner the peer chat had not sent within that budget, so its sent context was missing (CI failure on 775e668). The test now waits for the third send itself. Co-authored-by: Copilot <[email protected]>
…me folder precedence Review follow-ups for the 3a fixes: - noteCatalogNormalized is a cache refresh that never fails its caller: a failed refresh is logged and retried by the session's next locked load, so a committed migration no longer fails on it. The migration notes in a finally, so one that committed and then stopped still refreshes. - A missing session state after the flush is logged instead of silently keeping the legacy authority. - A cold peer without its own pin resumes in the live default session's folder before the host-supplied launch folder, as on main; a test pins that precedence. Co-authored-by: Copilot <[email protected]>
…tore test The test asserted session.db 50 ms after a coalesced write to a store with a 5 ms flush delay. On a loaded macOS runner the timed flush had started its write but not finished it (CI failure on 4b989f9). The test now waits for the timed write to start and then for that write. Co-authored-by: Copilot <[email protected]>
… terminal state An archived session's worktree is removed, so its branch computation finds no Git repository (nonGit) without logging, and the status was restored to the previous one: computing, because stored branch diffs are not read back after a restart (D3). Main showed the stored diffs as ready; this build stayed computing. 69f2120 ended only the 'failed' kind. Now every branch computation without a result (failed, nonGit, or a session database that cannot be opened) restores an earlier ready or error result, and otherwise ends in a computeFailed error with a warning. Co-authored-by: Copilot <[email protected]>
…write per publish Publishing a legacy-catalog session's peers wrote each peer's working directories to the session state store in its own transaction with an immediate mirror flush, for every peer and on every membership change, also when nothing changed. With 1001 peers a single upsert made about 10,000 SQLite statements (0.2 s on main, 1.3 s here, and a timeout under slow I/O in "does not truncate authoritative current membership writes"). The peers' working directories are now recorded in one exclusive write per publish, only for peers whose central directories differ, and not at all when no peer changed. Each peer's own database is still written as on main. Co-authored-by: Copilot <[email protected]>
…he session flag tests The session flag and sandbox config tests waited 25 ms for the store's background write and then read session.db. On a loaded Windows runner the write had not landed (CI failure on ac9beb4), and with slowed SQLite all five fail. The writes are queued on the store synchronously when the action is dispatched, so the tests now await the store's whenIdle instead. Co-authored-by: Copilot <[email protected]>
Vritant Bhardwaj (vritant24)
previously approved these changes
Oct 15, 2026
Sandeep Somavarapu (sandy081)
force-pushed
the
agents/block3a-session-state-authority
branch
from
October 15, 2026 06:35
3642a3d to
0fd4a42
Compare
Sandeep Somavarapu (sandy081)
requested review from
Vritant Bhardwaj (vritant24)
and removed request for
Vritant Bhardwaj (vritant24)
October 15, 2026 06:35
Robo (deepak1556)
approved these changes
Oct 15, 2026
Robo (deepak1556)
left a comment
Collaborator
There was a problem hiding this comment.
Would be a good candidate to use stacked PR.
Sandeep Somavarapu (sandy081)
deleted the
agents/block3a-session-state-authority
branch
October 15, 2026 07:06
This was referenced Oct 15, 2026
Alexandru Dima (alexdima)
added a commit
that referenced
this pull request
Oct 18, 2026
… restoreSession tests (#342389) `a queued toggle still publishes when the session was evicted while it waited` dispatched two archive toggles and then waited a fixed 30 `timeout(0)` ticks (~120 ms in the Electron renderer, where chained zero-delay timers are clamped to ~4 ms) before asserting. The first, queue-holding toggle awaits a session-state-store write and a catalog write; on a slow Windows runner those outlasted the tick budget, so the queued second toggle had not run yet and both the eviction and the publish were still missing. The test was also vacuous: since agent-host.db became authoritative for session state (#341626), passive toggles write through the session state store, so the `HookedDb.setMetadataValues` hook that was meant to evict the live session while the second toggle waited never fired. The second toggle took the live path, and residency released the newly archived session afterwards, which still satisfied the assertion. Evict the live session from the holder's session-state-store write and await that eviction and the session's `root/sessionSummaryChanged` notification instead of counting ticks, and also assert that the eviction happened while the toggle was queued. Apply the same treatment to the remaining tick-counted waits in `restoreSession`: `passive metadata publishes before central catalog synchronization completes` now awaits the publish, and the `StartupRaceAgent` tests await signals for migration start and the first metadata read instead of a 50-tick `advanceUntil`. Co-authored-by: Copilot <[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.



Goal
This is Block 3a of moving chats between sessions, following Block 2b (#341406, opaque chat URIs).
agent-host.dbbecomes authoritative for session state. Each chat's own database holds only that chat's data. Whatever older builds read is written for them as write-only copies (the "mirror"), so a downgrade keeps working.Before this change, session-level state (config, flags, workspace, git and GitHub state, titles, read state) lived in each session's
session.db, mixed with data that belongs to individual chats. Moving a chat between sessions needs a clean split: state that belongs to the session, and data that belongs to a chat and can travel with it.Design
Session state store
IAgentHostSessionStateStoreis the single owner of central session state. It uses new, additive tables inagent-host.db(migration 15):session_state,session_state_values,session_folder_state,session_chat_stateandchat_row_mirror. Older builds never read them.loadimports a session from itssession.dbonce, then reconciles. For each entry, a mirror that differs from the recorded merge base was edited by an older build after a downgrade, and that edit wins. Otherwise central state wins.readWithoutImport,openMetadataWithoutImport,prefetchWithoutImport,readBaseBranchWithoutImport). Until a session is imported, itssession.dbstays its authority. A page or pass makes one batchedagent-host.dbquery, and a session written centrally after that query is read afresh.SessionStateNotASessionError).exclusivehandle and never calls back into the store for the same session. Tests drive every known nesting path end to end, so a re-entrant call would hang and fail.agentHostSessionStateOwnershipGuard.test.tsfails on any directsession.dbaccess to a store-owned key outside the store, its mirror and the database layer, except an allowlist with a justification for each entry. Keys passed through string constants and statics (such asCopilotAgent._META_*) are resolved like literals. It also fails if the removed central checkpoint or branch-changes state is reintroduced.Binding decisions
configValues,customizationEnablement,isArchived,isRead,defaultChatIsRead,agentHost.autoArchivedAt,agentHost.workspaceless,agentHost.workspaceConversionQuarantined,agentHost.createdBySession.agentHost.sessionWorkingDirectories,agentHost.additionalWorktrees,copilot.worktree.*,sessionArtifacts.agentHost.git/gitData,github/githubData,pendingRecordedPullRequests,sourceControl,diffBaseBranch.vscode.scheduleCursorsis automation data.session_chat_statefor legacy-catalog sessions). The session database keeps receiving exactly main's writes.peerChatsis written only for legacy-catalog sessions, as on main.chatProviderData,chatOrigin,chatInheritedTurnId,chatWorkingDirectories,isRead).agentHost.chatWorkingDirectories, and only when its folders change. Releases 1.140 and 1.141 overlay that key on every read.refs/agents/chats/<chatKey>/checkpoints/turn/<N>, numbered per chat.agentHost.ehcliAdoptedandagentHost.ehcliLastMigratedTurnare the adopted chat's own data.async_hooks. There is no re-entrancy detection at runtime; the structural rule above is enforced by tests instead.Downgrade behaviour and accepted trade-offs
Performance
Measured with the agent host perf harness: seeded databases with 2,000 and 10,000 sessions, base and branch interleaved, every SQL statement diffed. Base is the merge base 50559e7; branch is 1f88938129b, before the P1, P2 and F3 fixes below.
agent-host.dbstatements are identical (7→7 at 2k, 27→27 at 10k).session.dbopens are 0→0.session.dbopens equal main's. The extra cost is one batched prefetch per sweep.session.dbwrite instead of 50).session.dbis gone; a normalized peer's folders are written only when they change.json_each) filter. The filter cost +25% per checkpoint lookup even with no foreign rows.How to test
Live validation in Code OSS with real Copilot, using Insiders 1.143 as the old build. Rounds 1–3 ran on 1f88938129b, before the live-finding fixes below. Round 4 re-checked the rebased head b823e919c4a, and round 5 the final head 89e2b7bab05.
Live findings fixed in this PR:
Validation
All commands ran on head 89e2b7bab05 (rebased onto main 59e0b82), with every
COPILOT_*,AGENT_HOST_*andGITHUB_TOKENvariable unset, except where a row names an earlier head:npm run typecheck-clientnpm run eslint -- <the 99 .ts/.js files changed vs origin/main>(b823e919c4a), then on the 26 files the gap fixes changed and the 4 files F8 changednpm run valid-layers-check./scripts/test.sh --reporter dot --grep "AgentHost|Chat"(ab3c1178993)./scripts/test.sh --reporter dot --grep "^(?!AgentHostChangesetStrategy ).*(AgentHost|Chat)"(89e2b7bab05, machine load ~20 from other apps)_doComputeStaticChangeset"after each" leak flake, at ab3c1178993 as well../scripts/test.sh --reporter dot --run src/vs/platform/agentHost/test/node/agentHostChangesetStrategy.test.ts, 3 times (89e2b7bab05, load ~11)./scripts/test.sh --reporter dot --run src/vs/platform/agentHost/test/node/agentService.test.ts(89e2b7bab05)./scripts/test.sh --reporter dot --run src/vs/platform/agentHost/test/node/agentHostSessionStateStore.test.ts(89e2b7bab05, incl. the F8 tests)./scripts/test-integration.sh --run src/vs/platform/agentHost/test/node/e2e/providers/copilotAgentHostE2E.integrationTest.ts(89e2b7bab05, strict replay)./scripts/test.sh --reporter dotwith--runfor agentService, copilotAgent, agentSideEffects, chatContributions, worktreeIsolation, sessionAdditionalWorktrees, agentHostSavedChatService, agentHostCustomizationEnablementService, agentHostSessionStateStore, agentHostSessionStateOwnershipGuard, agentHostGitStateService and the three turn/tool-call telemetry suites (src/vs/platform/agentHost/test/node/)npm run test-agent-host-e2e(strict replay, full profile, ab3c1178993)npm run test-agent-host-e2e-coverage(on cdd762d9844, before rebase)npm run smoketest-no-compile -- -g "Agents Window"(b823e919c4a)npm run smoketest-no-compile -- -g "Electron\) (Chat|Copilot CLI)"(b823e919c4a)it.skip. No test needed a real sign-in.After the final rebase onto main b575e28 (head 25818fc; conflicts were import lists and two tests both sides added, all kept), with the same variables unset:
npm run typecheck-clientnpm run eslint -- <the 103 .ts/.js files changed vs origin/main>npm run valid-layers-check./scripts/test.sh --reporter dot --grep "AgentHost|Chat"--run src/vs/platform/agentHost/test/node/agentHostGitStateService.test.ts: 78 passing, 0 failing./scripts/test.sh --reporter dot --runcopilotAgent, worktreeIsolation, agentHostSessionStateStore, agentHostSessionStateOwnershipGuard, agentSideEffects, agentHostCheckpointService, sessionDatabase (src/vs/platform/agentHost/test/node/)Main bumped
@github/copilot-sdkto 1.0.22-preview.2 after the last local E2E run; the private npm feed rejected the local install, so that SDK version is validated by CI only.Every behaviour fix has a mutation-checked test: the reverted change makes the test fail.
Not in this PR (follow-up issues)