Skip to content

fix: distinguish GitHub Copilot VSCode execution environment - #9420

Open
qinezh wants to merge 1 commit into
Azure:mainfrom
qinezh:qinezh/github-copilot-vscode-execution-environment
Open

fix: distinguish GitHub Copilot VSCode execution environment#9420
qinezh wants to merge 1 commit into
Azure:mainfrom
qinezh:qinezh/github-copilot-vscode-execution-environment

Conversation

@qinezh

@qinezh qinezh commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • preserve the existing vscode-copilot agent type and VS Code Azure GitHub Copilot telemetry value unchanged for BI compatibility; despite its historical name, this path represents the GitHub Copilot for Azure extension in VS Code
  • add the distinct github-copilot-vscode agent type for generic GitHub Copilot agent sessions in VS Code, detected only from the exact AI_AGENT=github_copilot_vscode_agent marker
  • report the new mode as GitHub Copilot VSCode through execution.environment, with host-specific detection before Copilot CLI fallback markers
  • add coverage for exact-value matching, Copilot-family precedence, terminal/no-prompt behavior, and execution-environment mapping
  • follow up on the Copilot surface attribution introduced in fix: distinguish GitHub Copilot App execution environment #9288

Testing

  • go test ./internal/runcontext/agentdetect -count=1
  • go test ./internal/terminal -count=1
  • go test ./internal/tracing/resource -count=1
  • go test ./cmd -run '^TestAgentDetectionIntegration$' -count=1

Fixes #9419

Copilot AI balanced review requested due to automatic review settings August 4, 2026 03:26
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
20 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@microsoft-github-policy-service

Copy link
Copy Markdown
Contributor

Thank you for your contribution @qinezh! We will review the pull request and get back to you soon.

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.

Pull request overview

Distinguishes GitHub Copilot agent sessions in VS Code across detection, CLI behavior, and telemetry.

Changes:

  • Adds exact AI_AGENT detection and Copilot precedence.
  • Maps the new agent type to GitHub Copilot VSCode.
  • Adds detection, terminal, no-prompt, and telemetry tests.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
docs/reference/telemetry-data.md Documents the telemetry value.
cli/azd/internal/tracing/resource/resource_test.go Tests execution-environment mapping.
cli/azd/internal/tracing/resource/exec_environment.go Maps the new agent type.
cli/azd/internal/tracing/fields/fields.go Defines the telemetry value.
cli/azd/internal/terminal/terminal_test.go Tests non-TTY behavior.
cli/azd/internal/runcontext/agentdetect/types.go Defines the agent type and display name.
cli/azd/internal/runcontext/agentdetect/detect_test.go Tests exact matching and precedence.
cli/azd/internal/runcontext/agentdetect/detect_env.go Detects the VS Code marker.
cli/azd/cmd/auto_install_integration_test.go Tests automatic no-prompt behavior.

Comment thread cli/azd/internal/runcontext/agentdetect/detect_env.go
Comment thread cli/azd/internal/tracing/fields/fields.go

@jongio jongio left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Traced the detection path and the telemetry mapping. The new AI_AGENT entry sits ahead of the Copilot CLI env vars in knownEnvVarPatterns, so Copilot VSCode wins over Copilot CLI when both are present, and detectFromEnvVars requires an exact value match so github_copilot_vscode_agent_extra correctly falls through. Existing vscode-copilot and its telemetry value are untouched, so BI continuity holds. Ran the agentdetect, terminal, and tracing/resource packages locally and they pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

customer-reported identify a customer issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Recognize GitHub Copilot in VS Code as a distinct execution environment

3 participants