Repository navigation
agent host: attribute provider send latency and trim host-side first turn overhead - #339016
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Configuration-triggered session restarts drop the recorder and misattribute launch latency to the refresh stage.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Adds provider-stage latency telemetry and reduces first-turn/checkpoint overhead in Agent Host.
Changes:
- Attributes provider dispatch-to-progress latency across telemetry, OTel, and logs.
- Parallelizes independent Copilot session startup work.
- Optimizes Git checkpoint capture with clean-tree and index-copy fast paths.
| File | Description |
|---|---|
common/agent.ts |
Adds the stage recorder to send context. |
common/agentHostTelemetry.ts |
Defines provider stages and recorder contract. |
common/otel/agentHostTiming.ts |
Exports stage timing attributes. |
node/agentHostTurnTracker.ts |
Records and logs stage durations. |
node/agentHostTelemetryReporter.ts |
Emits stage telemetry and OTel data. |
node/agentSideEffects.ts |
Creates the per-turn recorder. |
node/copilot/copilotAgent.ts |
Instruments and parallelizes session startup. |
node/copilot/copilotAgentSession.ts |
Marks model-response timing. |
node/copilot/copilotSessionLauncher.ts |
Times launch stages and parallelizes configuration. |
node/agentHostGitService.ts |
Adds checkpoint fast paths. |
node/agentHostCheckpointService.ts |
Overlaps baseline lookup with capture. |
OTEL.md |
Documents new timing fields and logs. |
test/node/copilotAgent.test.ts |
Tests peer-resume stage propagation. |
test/node/agentHostTurnTelemetry.test.ts |
Tests provider-stage telemetry boundaries. |
test/node/agentHostGitService.test.ts |
Tests index-copy eligibility. |
test/node/agentHostGitService.integrationTest.ts |
Tests checkpoint behavior across repository states. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Keep parseChangedPaths' JSDoc attached to it and drop a duplicated section divider. - Share one in-flight worktree-isolation git-info read per folder (from #338974). - Include epochMs in [ChatTTFP] trace lines to align with host timing (from #338974). Co-authored-by: Copilot <[email protected]>
# Conflicts: # src/vs/platform/agentHost/node/copilot/copilotSessionLauncher.ts # src/vs/platform/agentHost/node/shared/worktreeIsolation.ts
Contributor
Vijay Upadya (vijayupadya)
marked this pull request as ready for review
October 1, 2026 02:08
Vijay Upadya (vijayupadya)
enabled auto-merge (squash)
October 1, 2026 02:09
roblourens
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.

TL;DR
providerStage*Msfields inagentHost.turnCompletedand the OTelturn_timingspan break the time after dispatch into stages, from queue and client start through SDK create/resume to model response. The same breakdown appears in an[AgentHostFirstProgress]log line, and the renderer's[ChatTTFP]trace lines now carryepochMsso the two can be lined up. This is what will explain the Windows first-progress gap in production.git read-tree, and fall back to the old path whenever that isn't safe.Why
Agent-host (Copilot CLI) sessions are substantially slower to first progress than extension-host sessions, and the gap is mostly on Windows. Today's telemetry stops at "dispatched to the provider", but most of the time is spent after that. So we can't tell how much of it is client startup, customization snapshot, SDK session create/resume, or model latency. This PR adds that breakdown and removes some serial host-side work from the first turn.
Changes
Instrumentation
AgentHostProviderSendStage/IAgentProviderSendStageRecorder. The turn tracker records provider stages between dispatch and first progress:queue,refresh,client,snapshot,config,create,finalize,persist,turnPrepare,modelResponseproviderStage*MsinagentHost.turnCompletedand in the OTelturn_timingspan, and are documented inOTEL.md.0means it ran within timer resolution.[AgentHostFirstProgress]log line gives the same breakdown for local investigation.[ChatTTFP] start/endtrace lines includeepochMs(wall-clock), so local traces can be lined up with the host's[AgentHostFirstProgress]breakdown.Host-side latency
_buildSessionConfig(BYOK, shell tools and custom agents);captureWorkingTreeAsTree):git statusandHEAD^{tree}run in parallel.write-tree, so SHA-256 repos get their own empty tree.git read-tree HEAD. The index path is resolved withgit rev-parse --git-path index, so linked worktrees work.git statusentry can be restaged onto it (modified, added or untracked files, and deletions on disk). Staged deletions, renames, copies, conflicts, and files added then deleted (AD) fall back toread-tree, as does any failure._getGitInfocalls for the same folder share one in-flight read of repository root, current branch and default branch. Once it settles, the next caller reads git again, and a failed read isn't reused. This saves duplicate git processes when session config is resolved several times during startupResults
read-tree148 ms → index copy 3–4 mssend()returnedsend()returnedThis PR is incremental. The larger Windows costs are MCP startup blocking the turn, per-session runtime work and SDK session creation on first send; these are tracked separately.