Skip to content

agentHost: retain Copilot identity for edit-survival telemetry - #345691

Merged
Aaron Munger (amunger) merged 2 commits into
mainfrom
agents/fixing-issue-10569-pr
Nov 3, 2026
Merged

Aaron Munger (amunger) merged 2 commits into
mainfrom
agents/fixing-issue-10569-pr

Conversation

@amunger

@amunger Aaron Munger (amunger) commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes microsoft/vscode-internalbacklog#10569.

What and why

Copilot Agent Host commit-survival records now carry the originating account's common.copilotTrackingId, allowing tracking-ID-based analytics to admit and attribute those records. The issue's audit found the field missing from all qualifying records.

Capture the resolved tracking ID when the file tool starts, using the root turn or spawning subagent's account context, and retain it with the host's edit-source statistics until emission. If the user switches accounts before the commit, the earlier edit remains attributed to its original account rather than the account active at flush time.

Sources with different captured account IDs remain separate within the same reporting group. The existing telemetry helper supplies the common property; the ID is not included in protocol markers, flush responses, source-key strings, or persisted file snapshots. Missing IDs remain omitted, and other providers do not inherit Copilot identity.

How to test

The focused regression selection covers account changes during tools, root/peer/subagent dispatch, delayed standalone Git and client-coordinated commit flushes, cancelled/retried flushes, missing identity, non-Copilot providers, and protocol-data exclusion.

fnm exec --using 24.22.1 -- .\scripts\test.bat --run src\vs\platform\agentHost\test\node\agentEditAttributionService.test.ts --run src\vs\platform\agentHost\test\node\fileEditTracker.test.ts --run src\vs\platform\agentHost\test\node\copilotAgentSession.test.ts --grep "Agent Edit Attribution Service|FileEditTracker|tool_complete resolves relative apply_patch|tool_complete preserves the spawning subagent account" --reporter dot

Result after merging main: 76 passing.

Bravo review identified a missing identity assertion on the distinct Fusion-phase routing branch. The existing fixture now switches the exposed account between tool start and completion and verifies the originating ID:

fnm exec --using 24.22.1 -- .\scripts\test.bat --run src\vs\platform\agentHost\test\node\copilotAgentSession.test.ts --grep "tool_complete attributes unattributed edits inside a running HydraFusion phase" --reporter dot

Result: 1 passing.

Manual OSS validation

On November 3, launched the merged full Code OSS Agents build in an isolated profile, signed in to Copilot, and used its built-in edit tool in a disposable repository. Real Git commits triggered hashChange reporting; no synthetic event injection or production probes were used.

Scenario Inserted agent characters Retained agent characters Tracking ID
Agent changes pending to completed, then commit 9 9 Present; matches the originating session's agentHost.turnCompleted
Agent changes completed to verified; overwrite with XXXXXXXX before commit 8 0 Present; still matches the originating session

Both editTelemetry.editSources.details rows had origin=agentHost, provider=copilotcli, mode=longterm, and trigger=hashChange. Public source keys did not contain the tracking ID. No matching attribution errors appeared in the run's logs.

The live test used one account; account switching and subagents are covered by regression tests rather than live multi-account exercises. OSS telemetry was logging-only, so deployed ingestion and downstream scorecard inclusion still require post-deployment verification.

Capture the originating account tracking ID for file tools and preserve it in host edit-source state until delayed telemetry emission. Keep different accounts separate without exposing identity in protocol markers or source keys.

Fixes microsoft/vscode-internalbacklog#10569

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings November 2, 2026 23:38

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.

🟢 Approval recommended

No active review issues were identified for the change preserving originating account identity in edit-survival telemetry.

No open issues 🎉

What changed in this PR

This PR preserves the originating Copilot account identity in Agent Host edit-survival telemetry, so delayed commit reporting remains correctly attributed after an account switch.

Changes:

  • Captures the tracking ID at tool start from the root turn or spawning subagent and carries it through edit tracking.
  • Keeps account-specific statistics separate and emits the captured ID without adding it to protocol data or source-key strings.
  • Adds regression coverage for account changes, delayed and retried flushes, missing IDs, and non-Copilot providers.

Live telemetry ingestion remains unvalidated until deployment.

File Description
src/​vs/​platform/​agentHost/​test/​node/​fileEditTracker.test.ts Verifies tracking-ID forwarding to edit attribution.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgentSession.test.ts Tests account capture across root, peer, and subagent tool execution.
src/​vs/​platform/​agentHost/​test/​node/​agentEditAttributionService.test.ts Tests delayed attribution, flush retries, identity omission, and protocol exclusion.
src/​vs/​platform/​agentHost/​node/​shared/​fileEditTracker.ts Passes the captured identity into attribution records.
src/​vs/​platform/​agentHost/​node/​shared/​agentEditAttributionService.ts Separates statistics by account and emits the retained tracking ID.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Captures identity at tool start and forwards it at completion.
src/​vs/​platform/​agentHost/​common/​fileEditAttribution.ts Adds the optional host-only tracking ID to the attribution interface.

Review effort: Balanced

Preserve both account-isolation regressions and the new upstream attribution helper. Add the Bravo-requested regression assertion for account capture on Fusion phase edits.

Co-authored-by: Copilot <[email protected]>
@amunger
Aaron Munger (amunger) marked this pull request as ready for review November 3, 2026 18:13
@amunger
Aaron Munger (amunger) merged commit 4d699bd into main Nov 3, 2026
55 checks passed
@amunger
Aaron Munger (amunger) deleted the agents/fixing-issue-10569-pr branch November 3, 2026 18:51
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 3, 2026
Aaron Munger (amunger) added a commit that referenced this pull request Nov 5, 2026
* agentHost: retain Copilot identity for edit-survival telemetry (#345691)

Capture the originating account tracking ID for file tools and preserve it in host edit-source state until delayed telemetry emission. Keep different accounts separate without exposing identity in protocol markers or source keys.

Fixes microsoft/vscode-internalbacklog#10569

Co-authored-by: Copilot <[email protected]>

* Bump version to 1.145.1

Update Copilot Chat's VS Code engine requirement while retaining its 0.73.0 package version.

Co-authored-by: Copilot <[email protected]>

* Revert "Bump version to 1.145.1"

This reverts commit 2dac9e3.

* test: bound and retry apt in the WSL smoke setup (#345598)

* test: bound and retry apt in the WSL smoke setup

The Azure Ubuntu mirror usually serves the WSL smoke packages in 2-17
seconds, but a connection to it can fail or crawl for minutes. apt has
no minimum transfer speed, so a crawling download ran past the 300
second command timeout (2 PR CI failures in 48h), and apt-get update
only warns when it can't fetch the indexes, so the install then failed
to find docker.io (main CI 491631).

Bound the index update (now failing on any fetch error) and the package
download, and retry each on fresh connections. A retried download
resumes partial files.

Co-authored-by: Copilot <[email protected]>

* test: allow a slow mirror to finish the WSL smoke apt download across attempts

This PR's own CI hit the slow case: the indexes came at 8 MB/s, but
packages came at about 250 KB/s on every connection, so fresh connections
alone don't help. Each bounded attempt keeps completed packages and
resumes the partial one, so allow 5 download attempts and a 720 second
budget for the step.

Co-authored-by: Copilot <[email protected]>

* test: let a slow but progressing WSL smoke apt download use the whole budget

Instead of a hard per-attempt wall clock, which restarted a download
that was progressing at about 250 KB/s, fail only a connection that
stops sending data (Acquire::http::Timeout 30) and retry the download
on error.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Co-authored-by: Bryan Chen <[email protected]>
Aaron Munger (amunger) added a commit that referenced this pull request Nov 9, 2026
…346295)

* agentHost: preserve account identity across discovery cache expiry

Keep the tracking ID in the existing credential-scoped cell independently of endpoint and SKU freshness. Preserve identity on transient discovery failures while retaining authoritative replacement and invalidation behavior.

Follow-up to #345691.

Co-authored-by: Copilot <[email protected]>

* agentHost: preserve identity provenance through refresh failures

Keep the last published CAPI client separately from expiring discovery data so delayed credential rejection invalidates the correct account context without clearing newer discovery. Retain known identity even before a telemetry reader is captured.

Co-authored-by: Copilot <[email protected]>

---------

Co-authored-by: Copilot <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants