Adopt SDK-managed AHP subscriptions and retire duplicate reconnect lifecycle
- Dominant language
- TypeScript
- Stars
- 193k
- Forks
- 42.4k
- PR merge metrics
- PR metrics pending
Description
## Context
VS Code currently owns both application-specific agent state projection and generic Agent Host Protocol subscription lifetime machinery.
The generic lifetime portion is split across:
- src/vs/platform/agentHost/common/state/agentSubscription.ts in AgentSubscriptionManager
- src/vs/platform/agentHost/browser/agentHostProtocolClient.ts in reconnect inventory and restoration
The official TypeScript SDK now has a proposed shared lifetime owner in microsoft/agent-host-protocol#423. A tested dependent slice on joshmouch/agent-host-protocol branch pr/typescript-managed-host-subscriptions preserves one logical lease across transport generations and owns replay/snapshot/missing restoration plus generation fencing.
## Proposed coordinated cutover
1. Land the SDK shared-subscription slice in microsoft/agent-host-protocol#423.
2. Land the dependent host-generation lease slice in the official SDK.
3. Migrate VS Code AHP consumers to acquire named managed leases from the SDK.
4. Feed restored snapshots and actions from those leases into the existing VS Code state projections and pending-action reconciler.
5. Delete the superseded generic lifecycle owner in VS Code:
- currentSubscriptionUris reconnect inventory
- generic holder/refcount/final-unsubscribe bookkeeping
- generic subscription recreation after transport replacement
- replay-versus-snapshot and missing-resource lifecycle routing
- late-result and stale transport-generation fencing
- the subscription-lifecycle portion of _applyReconnectResult, applyReconnectSnapshot, and markSubscriptionsMissing
## Ownership boundary after the cutover
The official AHP SDK owns protocol-generic subscription identity, holder lifetime, reconnect generation, restoration status, missing-resource state, and final unsubscribe.
VS Code continues to own application semantics: TypeScript reducers, value and verifiedValue projections, per-resource routing, optimistic write-ahead actions, own-action acknowledgement, pending-action persistence and resend, createSession gating, URI/Event/Disposable adaptation, logging, telemetry, authentication, tunnels, and UI integration.
This proposal does not claim that the VS Code TypeScript reducers are generated or Microsoft AHP SDK reducers. Any reducer extraction should be a separate proposal with its own compatibility and ownership review. The handwritten C# reducers in the .NET AHP client were authored by Joshua Mouch and are also a separate provenance concern.
## Acceptance
- One logical subscription object survives a real transport replacement.
- Replay restoration, snapshot restoration, and missing-resource restoration use that same object.
- Events and late results from abandoned generations are ignored.
- Initial and managed owners may share a URI without duplicate subscribe or premature unsubscribe.
- Last-holder release sends exactly one unsubscribe through the current generation.
- Existing VS Code optimistic and confirmed state behavior remains green.
- Deleted VS Code code has no remaining caller or compatibility wrapper.
Related: microsoft/agent-host-protocol#423 and microsoft/agent-host-protocol#422.
Contributor guide
Assessment
This issue has not been assessed yet.