Skip to content

agentHost: retain SDK conversation IDs in restricted telemetry - #345609

Merged
Aaron Munger (amunger) merged 2 commits into
mainfrom
amunger/retain-sdk-engine-correlation
Nov 2, 2026
Merged

Aaron Munger (amunger) merged 2 commits into
mainfrom
amunger/retain-sdk-engine-correlation

Conversation

@amunger

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

Copy link
Copy Markdown
Collaborator

What and why

Make the existing Copilot SDK conversation identity available on restricted engine snapshots and their host text/tool counterparts, so downstream consumers can associate model calls with their conversation without introducing a host-provided correlation key.

The runtime already supplies the SDK session ID on its telemetry notification, but the restricted router previously forwarded only the event properties. This change retains that ID as sdkSessionId on engine.messages and engine.messages.length, and exposes the native child agent_id as sdkAgentId. Copilot user/model text and offered-tools events receive the matching sdkSessionId from the SDK wrapper that emitted the source event.

For example, a root engine call and its host text/tool events can now carry sdkSessionId: "sdk-a" even when the host resource is named differently. A child engine call carries that root ID plus its own sdkAgentId; consumers must keep child trajectories separate. The existing host conversationId and chatSessionId are not reinterpreted.

Related to microsoft/vscode-internalbacklog#9195.

Scope

This is client-side propagation using the current SDK, not a new SDK context API or dependency upgrade. It does not claim end-to-end AgentChatCurated recovery: CTS/schema/sharing still need to retain these properties, and curation still needs its admission, per-call pairing and decoding changes.

How to test

npm run build-fast -- --client-only

Passed (client transpilation; not a full type-check).

npm run test-node -- --run src/vs/platform/agentHost/test/node/agentHostGitHubTelemetryRouter.test.ts --run src/vs/platform/agentHost/test/node/agentHostTelemetryReporter.test.ts --run src/vs/platform/agentHost/test/node/agentHostRestrictedTelemetry.test.ts

Passed: 56 tests. Coverage includes authoritative notification IDs versus conflicting enrichment, missing IDs, root/child identities, independent conversations, existing host-ID semantics, restricted upload envelopes, compressed payloads and consent gates. Upload-envelope tests use an injected capture sink; no production telemetry or CTS ingestion was exercised.

npm run test-node -- --run src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts --grep "uses the originating chat rather than the persistence resource for compatibility telemetry"

Passed: the wrapper-driven producer regression and the test runner's error sentinel (2 passing). Distinct host and SDK IDs verify that the real event subscriptions supply the SDK ID to all three text/tools reporting paths.

Preserve the producing SDK session and child identities on restricted engine snapshots and carry the SDK session ID on host text/tool events. Keep host conversation fields independent and require no new runtime context API.

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

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 remain for the SDK telemetry identity-propagation changes.

No open issues 🎉

What changed in this PR

This PR preserves Copilot SDK conversation identity in Agent Host restricted telemetry so downstream consumers can associate engine calls with host text and tool events without changing existing host identifiers.

Changes:

  • Retains authoritative sdkSessionId and child sdkAgentId values on restricted engine events.
  • Passes the emitting SDK wrapper’s session ID to user/model text and offered-tools telemetry.
  • Adds identity-propagation tests, telemetry classifications, and documentation; backend retention remains separate work.

No actionable findings remain. The reported validation covers client transpilation and 56 targeted tests, but not full type-checking or production telemetry ingestion.

File Description
src/​vs/​platform/​agentHost/​test/​node/​agentHostTelemetryReporter.test.ts Tests SDK identity propagation, missing IDs, and unchanged host grouping.
src/​vs/​platform/​agentHost/​test/​node/​agentHostGitHubTelemetryRouter.test.ts Tests authoritative identities, child calls, upload envelopes, and consent gates.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Passes the emitting SDK wrapper’s session ID to telemetry methods.
src/​vs/​platform/​agentHost/​node/​agentHostTelemetryReporter.ts Adds optional SDK identity to restricted text/tool events and declares its classification.
src/​vs/​platform/​agentHost/​node/​agentHostGitHubTelemetryRouter.ts Retains SDK conversation and child identifiers on engine events.
src/​vs/​platform/​agentHost/​AGENTS.md Documents identity semantics, privacy controls, and downstream limitations.

Review effort: Balanced

Use distinct host and SDK session IDs in the existing wrapper-driven telemetry regression so omitting or misattributing any text/tool SDK ID fails the test.

Co-authored-by: Copilot <[email protected]>
@amunger
Aaron Munger (amunger) marked this pull request as ready for review November 2, 2026 19:58
@amunger
Aaron Munger (amunger) merged commit 3b3bea4 into main Nov 2, 2026
55 checks passed
@amunger
Aaron Munger (amunger) deleted the amunger/retain-sdk-engine-correlation branch November 2, 2026 23:02
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 2, 2026
Aaron Munger (amunger) added a commit that referenced this pull request Nov 3, 2026
#345688)

agentHost: retain SDK conversation IDs in restricted telemetry (#345609)

* agentHost: retain SDK conversation IDs in restricted telemetry

Preserve the producing SDK session and child identities on restricted engine snapshots and carry the SDK session ID on host text/tool events. Keep host conversation fields independent and require no new runtime context API.



* agentHost: test SDK correlation at the event producer boundary

Use distinct host and SDK session IDs in the existing wrapper-driven telemetry regression so omitting or misattributing any text/tool SDK ID fails the test.



---------


(cherry picked from commit 3b3bea4)

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