sessions: Prepare sandbox repositories before session creation - #336294
Osvaldo Ortega (osortega) wants to merge 2 commits into
Conversation
Resolve a ready host checkout after authentication before creating a sandbox session. Keep project requests capability-gated, preserve legacy hosts, and align customization scopes with the prepared directory. Surface clone failures and cancellation, allow explicit retries, and bound clone acknowledgement and readiness with one deadline. Add focused regression coverage and document the client lifecycle. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Cancellation does not stop queued extension requests, and preparation failures are misclassified in telemetry.
Get a fresh assessment by requesting another Copilot review.
Review tier: Balanced
Findings: 1
Open (2)
What changed in this PR
Adds host-side repository preparation to remote sandbox session creation.
Changes:
- Resolves or clones sandbox repositories before session creation.
- Rebinds workspace customizations to prepared directories.
- Adds capability checks, cancellation, progress, documentation, and tests.
| File | Description |
|---|---|
agentHostChatContribution.test.ts |
Tests preparation lifecycle and scope rebinding. |
agentHostSessionHandler.ts |
Adds pre-creation directory preparation. |
cloudSandboxProjectResolver.test.ts |
Covers clone, reuse, failure, and cancellation paths. |
cloudSandboxAgentHostContribution.test.ts |
Stubs the new progress dependency. |
REMOTE_AGENT_HOST_SESSIONS_PROVIDER.md |
Documents remote workspace preparation. |
remoteAgentHostConnectionCustomization.ts |
Exposes the preparation customization hook. |
remoteAgentHost.contribution.ts |
Connects preparation to session handling. |
cloudSandboxProjectResolver.ts |
Implements host checkout resolution and cloning. |
cloudSandboxConnectionCustomization.ts |
Enables preparation for sandbox connections. |
cloudSandboxAgentHostContribution.ts |
Instantiates and registers the resolver. |
copilotChatSessionsProvider.ts |
Reuses the shared repository parser. |
gitHubRepository.ts |
Provides shared GitHub repository parsing. |
agentHostProtocolClient.test.ts |
Tests host-specific extension requests. |
agentHostProjectMeta.ts |
Validates project-management capability metadata. |
agentService.ts |
Adds extension requests to the connection API. |
agentHostProtocolClient.ts |
Dispatches extension JSON-RPC requests. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| const response = await raceCancellationError(connection.requestExtension('extensions/cloneProject', { | ||
| url: `https://github.com/${repository}`, | ||
| depth: 1, | ||
| }), cts.token); |
| onFailureStage?.('createSession'); | ||
| const requestedDirectory = this._resolveRequestedWorkingDirectory(sessionResource); | ||
| const preparedDirectory = this._config.prepareWorkingDirectory | ||
| ? await this._config.prepareWorkingDirectory(sessionResource, requestedDirectory, cancellationToken) |
|
Base:
|
Remove arbitrary RPC dispatch from the shared agent connection. Keep the low-level sender on the concrete transport and expose validated project operations through a connection-owned sandbox adapter. Bind preparation to the exact connection lifetime, cancel outstanding work on teardown, and preserve replacement connections at the same address. Add adapter and factory regression coverage and document the narrowed client boundary without changing the AHP wire contract. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Closed in favor of a protocol-first repository-session design. Replacement drafts: microsoft/agent-host-protocol#451 defines optional schema-discovered repository intent, and #336361 consumes that contract through ordinary session creation. The new client draft does not carry this PR’s vendor-cloning adapter. Both remain drafts pending protocol and interoperability review. |


Summary
Prepare the selected repository on a capable sandbox host before creating the session, rather than assuming that connecting also supplies a ready checkout.
Protocol boundary
The shared
IAgentConnectioninterface does not expose arbitrary RPC dispatch. The concrete transport client retains the low-level host-extension sender, whileCloudSandboxProjectsClientexposes typed project operations and validates the capability, catalogue entries, and clone response. The resolver no longer names wire methods or handles untyped RPC responses.The sandbox connection factory owns each adapter by connection identity. Teardown cancels preparation and removes only that connection's adapter, leaving a replacement at the same address intact. No standard AHP schema, command-map, protocol-version, or clone wire-payload changes are introduced.
Validation
npm run typecheck-clientpassed.npm run valid-layers-checkandgit diff --checkpassed.Manual verification still needed
Full-build and live-sandbox/end-to-end verification have not been run.