Skip to content

agentHost: lazily restore peer chats - #329071

Merged
Connor Peet (connor4312) merged 3 commits into
mainfrom
connor4312/agenthost-lazy-peer-chat-restore
Aug 5, 2026
Merged

Connor Peet (connor4312) merged 3 commits into
mainfrom
connor4312/agenthost-lazy-peer-chat-restore

Conversation

@connor4312

Copy link
Copy Markdown
Member

Summary

  • keep restored peer chats as state-manager-owned catalog entries until their content is requested
  • resolve peer chat SDK histories lazily and atomically, coalescing duplicate requests while allowing distinct peers to resume in parallel
  • consolidate per-session resume, sequencing, lease, and teardown coordination in CopilotSessionLifetime
  • preserve peer metadata, retry/invalidation behavior, legacy migration, and subagent restoration
  • add an opt-in events.jsonl restoration benchmark and update the multi-chat architecture documentation

This avoids eagerly resuming every peer SDK session when opening a parent session, which could turn ten roughly three-second restores into a roughly thirty-second load.

Validation

  • npm run transpile-client
  • targeted Agent Host unit tests
  • hygiene checks for all changed TypeScript files
  • git diff --check
  • npm run typecheck-client has no errors in changed files; existing unrelated errors remain in native/electron-main/auth.ts and component fixture utilities

Keep restored peer chats as state-manager-owned entries and materialize their SDK histories only when content is requested. Consolidate per-session resume, sequencing, and teardown coordination so distinct peers can resume concurrently without racing session disposal.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings August 4, 2026 23:19
@connor4312
Connor Peet (connor4312) enabled auto-merge (squash) August 4, 2026 23:19
…lazy-peer-chat-restore

# Conflicts:
#	src/vs/platform/agentHost/node/agentService.ts

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.

Pull request overview

Lazily restores peer-chat histories while preserving catalog metadata and coordinating concurrent SDK session lifecycles.

Changes:

  • Adds state-manager-owned lazy peer-chat resolution with coalescing and invalidation.
  • Consolidates Copilot session sequencing, leases, resume, release, and disposal.
  • Adds restoration tests, benchmarking, and architecture documentation.
Show a summary per file
File Description
MULTI_CHAT_ARCHITECTURE.md Documents lazy restoration architecture.
agentHostStateManager.ts Adds lazy chat entries and resolvers.
agentService.ts Registers and resolves restored chats on demand.
copilotAgent.ts Introduces coordinated session lifetimes.
sessionServerTools.ts Makes chat-context retrieval asynchronous.
agentHostStateManager.test.ts Tests resolver state and invalidation.
agentService.test.ts Tests lazy orchestration behavior.
copilotAgent.test.ts Tests resume and teardown concurrency.
mapSessionEvents.perf.test.ts Adds opt-in restoration benchmark.
sessionServerTools.test.ts Updates asynchronous context mocks.

Review details

Suppressed comments (1)

src/vs/platform/agentHost/node/agentService.ts:2044

  • A failed provider deletion now leaves every restored peer resolver permanently invalid even though the session remains in the catalog. provider.disposeSession can reject (the Copilot path explicitly supports retrying after an SDK delete error), but this invalidation is not rolled back; subsequent resolveChatState calls return undefined, so an unresolved peer cannot be opened before the user retries deletion. Invalidate only once teardown is committed, or add a rollback path that re-enables the entries when any later teardown step fails.
		// The host owns branch completions for every agent (they share the same
  • Files reviewed: 10/10 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Propagate known peer-session resume failures so lazy chat hydration remains retryable instead of committing an empty history.

Co-authored-by: Copilot <[email protected]>
@connor4312
Connor Peet (connor4312) merged commit aa23e75 into main Aug 5, 2026
29 checks passed
@connor4312
Connor Peet (connor4312) deleted the connor4312/agenthost-lazy-peer-chat-restore branch August 5, 2026 00:30
@vs-code-engineering vs-code-engineering Bot added this to the 1.133.0 milestone Aug 5, 2026
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Sep 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants