Skip to content

Add X-Interaction-Type header and requestKind telemetry property for chat requests#312262

Merged
isidorn merged 15 commits intomicrosoft:mainfrom
kevin-m-kent:kevin-m-kent/telemetry-request-kind
May 6, 2026
Merged

Add X-Interaction-Type header and requestKind telemetry property for chat requests#312262
isidorn merged 15 commits intomicrosoft:mainfrom
kevin-m-kent:kevin-m-kent/telemetry-request-kind

Conversation

@kevin-m-kent
Copy link
Copy Markdown
Contributor

@kevin-m-kent kevin-m-kent commented Apr 23, 2026

Sets the X-Interaction-Type header on outgoing chat requests and emits a matching requestKind property on response.success, response.cancelled, and response.error telemetry events.

The primary purpose of this property is to filter out background events in both VSCode and CAPI A/B scorecards.

Changes

  • Default X-Interaction-Type to the location-derived intent (conversation-panel, conversation-agent, conversation-inline, conversation-edits, conversation-notebook, conversation-terminal, conversation-other).
  • Add an interactionTypeOverride option ('conversation-subagent' | 'conversation-compaction' | 'conversation-background') for callers that aren't well-described by location:
    • conversation-subagent: execution / search subagent loops.
    • conversation-compaction: mid-loop history compaction (summarizedConversationHistory, agent background compaction).
    • conversation-background: title / git-branch / prompt-categorizer / progress-messages / cheap-model summarizer / background todo processor.
  • Emit the resolved value as requestKind on the three response telemetry events (with GDPR entries).

Notes

Emit a new 'requestKind' property on response.success, response.cancelled,
and response.error. Values: 'background', 'subagent', or 'normal' (derived
from the same requestKindOptions that sets the X-Interaction-Type header).

This lets us distinguish background and subagent requests from primary user
requests in telemetry, complementing the existing initiatorType (user/agent)
signal.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 23, 2026 23:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends Copilot chat response telemetry to include a requestKind dimension ('normal' | 'background' | 'subagent') on the CAPI path, derived from existing requestKindOptions that already influence the X-Interaction-Type header. This enables slicing success/cancel/error metrics by request kind without changing runtime behavior.

Changes:

  • Adds requestKindOptions to the telemetry payload interfaces and emits requestKind on response.success, response.cancelled, and response.error.
  • Updates the GDPR schemas for the three events to include requestKind (SystemMetaData / FeatureInsight).
  • Threads requestKindOptions through ChatMLFetcherImpl success/cancel/error telemetry call paths (including retry/error paths).
Show a summary per file
File Description
extensions/copilot/src/extension/prompt/node/chatMLFetcherTelemetry.ts Adds requestKind emission and GDPR schema entries for success/cancel/error response telemetry.
extensions/copilot/src/extension/prompt/node/chatMLFetcher.ts Passes requestKindOptions through to telemetry senders and into processSuccessfulResponse.

Copilot's findings

  • Files reviewed: 2/2 changed files
  • Comments generated: 0

kevin-m-kent and others added 9 commits April 29, 2026 10:32
…estId on response.cancelled/error

Inverts requestKind defaulting in chatMLFetcher.fetchMany so that any
request reaching the fetcher without an explicit requestKindOptions is
classified as 'background'. Adds 'mainagent' as the explicit opt-in for
primary user-driven turns. Now:

- defaultIntentRequestHandler passes { kind: 'subagent' } for subagents
  and { kind: 'mainagent' } for normal user turns.
- inlineChatIntent (both chat2 and inline edit paths) passes
  { kind: 'mainagent' }.
- All other callers (title gen, summarization, intent detection, commit
  message gen, terminal fix gen, PR title/desc gen, rename suggestions,
  semantic search, virtualToolGrouper, etc.) automatically get
  'background' without per-call edits.

Also adds parentRequestId and conversationId to response.success,
response.cancelled, and response.error events so subagent requests can
be joined back to the main agent request, matching the
panel.request schema.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Conversation history summarization is in the critical path of a user
turn (it gates the next agent step), so classifying it as 'background'
alongside truly out-of-band utility calls (chat title gen, intent
detection, commit message gen, etc.) loses an important signal.

Adds a 'summarization' kind and marks both summarization sites
(SummarizedConversationHistory full/simple path and AgentIntent
inline path) explicitly.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- executionSubagentToolCallingLoop: explicitly set kind: 'subagent'
  (was defaulting to 'background')
- ChatSummarizerProvider (vscode.ChatSummarizer): kind: 'summarization'
  (was defaulting to 'background'). Switched the call from positional
  makeChatRequest to makeChatRequest2 so requestKindOptions can be passed.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collapse the four IBackgroundRequestOptions / ISubagentRequestOptions /
ISummarizationRequestOptions / IMainAgentRequestOptions interfaces into
a single 'as const' object + derived type, matching the existing
ToolName / ContributedToolName pattern in this codebase. Call sites now
use RequestKind.MainAgent etc. instead of hand-typing 'mainagent', so a
future rename only has to update the RequestKind definition.

Compile-time safety is unchanged — IRequestKindOptions.kind is still
typed as the union of literals.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
# Conflicts:
#	extensions/copilot/src/extension/inlineChat2/node/inlineChatIntent.ts
xtabProvider and xtabNextCursorPredictor were defaulting to 'background'
but they're a distinct workload (speculative inline edit prediction with
different cost/latency/cache characteristics than other utility
callers). Tag them as 'nes' so telemetry can slice them out.

Header behavior unchanged — 'nes' falls through to the location-derived
intent on X-Interaction-Type, like 'mainagent' and 'summarization'.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add resolveInteractionType helper that maps RequestKind+intent to
  conversation-* values matching the server's documented vocabulary:
  Subagent → conversation-subagent, Background → conversation-background,
  Summarization → conversation-agent, Nes → conversation-other,
  MainAgent → location-derived (panel/inline/edits/agent/other).
- Unify chatMLFetcher and networking.ts header paths via the helper, so
  X-Interaction-Type is now set unconditionally on every request (panel,
  inline, edits, etc.) instead of only for subagent/background/agent.
- Telemetry property 'requestKind' now emits the resolved interaction
  type (matches the wire header value exactly) instead of the internal
  enum string. GDPR comments updated.
- Flip newNotebookIntent (3 sites) and setupTestsInvocation (2 sites) —
  which run on the user's main agent model — from the Background default
  to MainAgent so they no longer report as background traffic.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
RequestKind is now { MainAgent, Subagent, Background } — 1:1 with the
server's X-Interaction-Type taxonomy. Summarization and NES sites use
MainAgent and rely on location to resolve to conversation-agent /
conversation-other respectively.

- summarizer.ts: location Panel -> Agent
- summarizedConversationHistory.tsx: location Other -> Agent
- agentIntent inline summarization: kind Summarization -> MainAgent
- xtabProvider / xtabNextCursorPredictor: kind Nes -> MainAgent

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
kevin-m-kent and others added 4 commits May 4, 2026 18:54
ChatSummarizerProvider.provideChatSummary runs on copilot-fast
(inexpensive), is not user-initiated, and isn't tied to an active user
turn — VS Code calls it on its own to produce a summary string for
session metadata. That fits the server's conversation-background
definition ("background requests on inexpensive models that can't be
associated with a user interaction"), not conversation-agent.

The other two summarization sites (summarizedConversationHistory.tsx
and agentIntent inline summarization) stay on MainAgent + Agent
location since they sit in the critical path of an active user turn.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Removes the RequestKind enum (MainAgent/Subagent/Background) and the
opt-out-of-background-default pattern. Instead callers explicitly pass
interactionTypeOverride: 'conversation-subagent' | 'conversation-compaction'
| 'conversation-background' when they need to deviate from the
location-derived intent. Unmarked calls now fall through to the
location-derived value (conversation-panel/inline/edits/agent/etc.)
instead of silently defaulting to background.

Concrete classifications:
- vscode.ChatSummarizer (cheap-model summary):  conversation-background
- mid-agent-loop history compaction:            conversation-compaction
- agentIntent background compaction:            conversation-compaction
- title / git-branch / promptCategorizer /
  inline-chat progress messages /
  backgroundTodoProcessor:                      conversation-background
- search/exec subagents + subagent turns:       conversation-subagent
- everything else:                              location-derived

Drops 11 redundant RequestKind.MainAgent markers (no-ops).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…celled/error

These id-coverage telemetry additions are independent of the requestKind /
X-Interaction-Type change in this PR, and are being moved to a separate
follow-up PR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@kevin-m-kent kevin-m-kent changed the title Add requestKind to chat response telemetry events Add X-Interaction-Type header and requestKind telemetry property for chat requests May 5, 2026
@isidorn isidorn assigned roblourens and unassigned dileepyavan May 5, 2026
roblourens
roblourens previously approved these changes May 5, 2026
Yoyokrazy
Yoyokrazy previously approved these changes May 5, 2026
@isidorn isidorn enabled auto-merge May 6, 2026 06:06
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
auto-merge was automatically disabled May 6, 2026 12:13

Head branch was pushed to by a user without write access

@kevin-m-kent kevin-m-kent dismissed stale reviews from Yoyokrazy and roblourens via 4b118cf May 6, 2026 12:13
@isidorn isidorn enabled auto-merge May 6, 2026 12:47
@isidorn isidorn merged commit 262545e into microsoft:main May 6, 2026
29 of 49 checks passed
@vs-code-engineering vs-code-engineering Bot added this to the 1.120.0 milestone May 6, 2026
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.

7 participants