Add X-Interaction-Type header and requestKind telemetry property for chat requests#312262
Merged
isidorn merged 15 commits intomicrosoft:mainfrom May 6, 2026
Merged
Conversation
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>
Contributor
There was a problem hiding this comment.
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
requestKindOptionsto the telemetry payload interfaces and emitsrequestKindonresponse.success,response.cancelled, andresponse.error. - Updates the GDPR schemas for the three events to include
requestKind(SystemMetaData / FeatureInsight). - Threads
requestKindOptionsthroughChatMLFetcherImplsuccess/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
…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>
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>
roblourens
previously approved these changes
May 5, 2026
Yoyokrazy
previously approved these changes
May 5, 2026
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
isidorn
approved these changes
May 6, 2026
alexr00
approved these changes
May 6, 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.
Sets the
X-Interaction-Typeheader on outgoing chat requests and emits a matchingrequestKindproperty onresponse.success,response.cancelled, andresponse.errortelemetry events.The primary purpose of this property is to filter out background events in both VSCode and CAPI A/B scorecards.
Changes
X-Interaction-Typeto the location-derived intent (conversation-panel,conversation-agent,conversation-inline,conversation-edits,conversation-notebook,conversation-terminal,conversation-other).interactionTypeOverrideoption ('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.requestKindon the three response telemetry events (with GDPR entries).Notes
parentRequestId/conversationIdcoverage on response.* events.