agent host: overlap provider session startup with the turn-start checkpoint (experiment) - #339053
Merged
Merged
Conversation
Copilot started reviewing on behalf of
Vijay Upadya (vijayupadya)
October 1, 2026 06:31
View session
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Configuration changes during preparation can be missed, and cancelled prepared chats leak marker entries.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Overlaps Copilot provider session preparation with checkpoint capture to reduce first-turn latency behind an experiment gate.
Changes:
- Adds provider preparation hooks and Copilot session materialization.
- Adds experiment configuration, triggering, and tests.
- Adds provider-preparation timing to telemetry and OTel.
| File | Description |
|---|---|
common/agent.ts |
Defines the preparation hook. |
common/agentHostSchema.ts |
Adds host configuration schema. |
common/agentHostStarter.config.contribution.ts |
Registers the experiment setting. |
common/agentService.ts |
Defines the setting ID. |
common/agentHostTelemetry.ts |
Adds the preparation timing stage. |
common/otel/agentHostTiming.ts |
Exposes timing through OTel. |
node/agentSideEffects.ts |
Coordinates preparation and checkpoint capture. |
node/copilot/copilotAgent.ts |
Implements Copilot preparation and refresh skipping. |
node/agentHostTelemetryReporter.ts |
Reports the new timing measurement. |
OTEL.md |
Documents the timing attribute. |
test/node/agentSideEffects.test.ts |
Tests overlap and experiment behavior. |
test/node/copilotAgent.test.ts |
Tests materialization and refresh skipping. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Contributor
Vijay Upadya (vijayupadya)
marked this pull request as ready for review
October 1, 2026 19:56
Vijay Upadya (vijayupadya)
enabled auto-merge (squash)
October 1, 2026 19:56
Vijay Upadya (vijayupadya)
marked this pull request as draft
October 1, 2026 19:56
auto-merge was automatically disabled
October 1, 2026 19:56
Pull request was converted to draft
# Conflicts: # src/vs/platform/agentHost/common/agentHostStarter.config.contribution.ts # src/vs/platform/agentHost/test/node/agentSideEffects.test.ts
Vijay Upadya (vijayupadya)
marked this pull request as ready for review
October 1, 2026 20:41
Vijay Upadya (vijayupadya)
enabled auto-merge (squash)
October 1, 2026 20:41
roblourens
approved these changes
Oct 1, 2026
Aaron Munger (amunger)
approved these changes
Oct 1, 2026
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.

Follow-up to #339016
TL;DR
chat.agentHost.experimental.overlapProviderPreparation, default off, for an ExP rollout. A trigger event marks exposure in both arms.Why
On a first turn, the agent host waits for the turn-start checkpoint (
git statusand a tree capture), then dispatches. Only then does the Copilot provider create the SDK session (client, customization snapshot, config, create/resume). On Windows each costs 0.3–1 s, and they ran back to back. They don't depend on each other: the provider can't touch the workspace before the prompt is sent, so session creation can run alongside the checkpoint.Changes
IAgentChats.prepareTurn(chat, turnId, workingDirectories, context): optional provider hook to set up session state before the send. It must not send a prompt or modify the working tree. Providers that don't implement it behave exactly as before.AgentSideEffects: when the setting is on, startsprepareTurnright after the turn's model and agent selection is applied. It runs alongside attachments, contributions and the checkpoint capture, and the dispatch waits for both.sendMessagethen prepares as usual, so errors surface exactly as they do without the overlap.prepareTurncreates the session for a not-yet-started chat, or resumes the default or peer chat's session, if the chat has no live session. It runs on the same per-chat queue assendMessageand retries a failed plugin sync first, as the send path does.sendMessageskips the snapshot-based configuration re-check: plugin-sync retry, customization snapshot,getRestartReason, disabled root MCP servers. The session was just created with that state. Explicit restart flags and additional-directory changes are still honored. Keying on the turn ID means a cancelled turn's leftover marker can never affect a later turn.chat.agentHost.experimental.overlapProviderPreparation(application scope,experiment: { mode: 'auto' }), forwarded to the agent host as the root keyoverlapProviderPreparation. It's a rollout gate, not an enterprise control, so it has no policy entry.sendStageProviderPreparationMsinagentHost.turnCompleted, the OTelturn_timingspan andOTEL.md: the time dispatch still waits for preparation after the overlap, not the preparation's total cost.providerStage*Ms.logSettingExperimentTrigger) fires in both arms once a turn reaches a provider that implementsprepareTurn. It waits until the workbench has forwarded the assignment context, likeAgentHostGitStateService.Results
MSBench
say_hello(Linux) andsay_hello_windows(Windows Server 2022) containers. Both arms use the same build (Insiders0d30d69with #339016 and this change) and differ only in the setting. 4 runs per cell. Time from turn start untilsession.send()returns, p50:sendStageProviderPreparationMs, so the treatment applied in all of them.create,finalize,persist,snapshot) disappear. Evaluate the experiment on time to first progress, nottimeToProviderDispatch.sendMessagere-checked the configuration of the sessionprepareTurnhad just created, which cancelled out the overlap.