Skip to content

Add copilot-app LLM environment telemetry detection - #55440

Merged
marcpopMSFT merged 1 commit into
mainfrom
marcpopmsft-add-copilot-app-telemetry-detection
Jul 23, 2026
Merged

marcpopMSFT merged 1 commit into
mainfrom
marcpopmsft-add-copilot-app-telemetry-detection

Conversation

@marcpopMSFT

Copy link
Copy Markdown
Member

Summary

Add a new "copilot-app" detection rule for the GitHub Copilot desktop application (Copilot CLI app), which sets AI_AGENT=github_copilot_app_agent when running dotnet CLI commands.

This is separate from:

  • "copilot-cli" — detects the CLI tool itself via COPILOT_CLI=1 and related presence vars
  • "copilot-vscode" — detects VS Code agent mode via AI_AGENT=github_copilot_vscode_agent

When running inside the Copilot desktop app, both copilot-cli and copilot-app rules will fire, resulting in a telemetry value like "copilot-cli, copilot-app".

Changes

  • src/Cli/dotnet/Telemetry/LLMEnvironmentDetectorForTelemetry.cs: Added new EnvironmentVariableValueRule("AI_AGENT", "github_copilot_app_agent") rule mapped to "copilot-app".
  • test/dotnet.Tests/TelemetryTests/TelemetryCommonPropertiesTests.cs:
    • Added test cases for single-var copilot-app detection and combo copilot-cli + copilot-app detection.
    • Fixed the CanDetectLLMStatusForEnvVars test to save/restore all ambient LLM env vars before each test case, so tests pass correctly when the test process itself runs inside an LLM agent environment.
    • Made TelemetryCommonPropertiesShouldReturnIsLLMDetection resilient to ambient LLM env vars.

Add a new 'copilot-app' detection rule for the GitHub Copilot desktop
application which sets AI_AGENT=github_copilot_app_agent. This is
separate from the existing 'copilot-vscode' rule (VS Code agent mode)
and 'copilot-cli' rule (CLI presence).

Also fix the LLM environment tests to save/restore ambient environment
variables so they pass correctly when the test process runs inside an
LLM agent environment (e.g. the Copilot CLI app).

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings July 23, 2026 21:06
@marcpopMSFT
marcpopMSFT requested a review from a team as a code owner July 23, 2026 21:06
@azure-pipelines

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

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

This PR extends the dotnet CLI’s LLM-environment telemetry to recognize the GitHub Copilot desktop app by detecting AI_AGENT=github_copilot_app_agent, and updates telemetry tests to be resilient to “ambient” agent environment variables when running under an LLM-hosted test process.

Changes:

  • Add a new "copilot-app" detection rule based on AI_AGENT=github_copilot_app_agent.
  • Add/adjust telemetry test cases for "copilot-app" alone and combined "copilot-cli, copilot-app" detection.
  • Add test isolation to clear/restore all LLM-related environment variables per test case to avoid pollution from the runner’s environment.

Reviewed changes

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

File Description
src/Cli/dotnet/Telemetry/LLMEnvironmentDetectorForTelemetry.cs Adds "copilot-app" detection based on AI_AGENT value.
test/dotnet.Tests/TelemetryTests/TelemetryCommonPropertiesTests.cs Adds "copilot-app" test cases and improves env-var isolation for LLM detection tests.

@marcpopMSFT
marcpopMSFT merged commit 36c0dfd into main Jul 23, 2026
30 checks passed
@marcpopMSFT
marcpopMSFT deleted the marcpopmsft-add-copilot-app-telemetry-detection branch July 23, 2026 22:53
@marcpopMSFT

Copy link
Copy Markdown
Member Author

/backport to release/10.0.4xx

@github-actions

Copy link
Copy Markdown
Contributor

Started backporting to release/10.0.4xx (link to workflow run)

@github-actions

Copy link
Copy Markdown
Contributor

@marcpopMSFT backporting to release/10.0.4xx failed, the patch most likely resulted in conflicts. Please backport manually!

git am output
$ git am --3way --empty=keep --ignore-whitespace --keep-non-patch changes.patch

Applying: Add copilot-app LLM environment telemetry detection
Using index info to reconstruct a base tree...
M	src/Cli/dotnet/Telemetry/LLMEnvironmentDetectorForTelemetry.cs
A	test/dotnet.Tests/TelemetryTests/TelemetryCommonPropertiesTests.cs
Falling back to patching base and 3-way merge...
Auto-merging src/Cli/dotnet/Telemetry/LLMEnvironmentDetectorForTelemetry.cs
CONFLICT (content): Merge conflict in src/Cli/dotnet/Telemetry/LLMEnvironmentDetectorForTelemetry.cs
CONFLICT (modify/delete): test/dotnet.Tests/TelemetryTests/TelemetryCommonPropertiesTests.cs deleted in HEAD and modified in Add copilot-app LLM environment telemetry detection.  Version Add copilot-app LLM environment telemetry detection of test/dotnet.Tests/TelemetryTests/TelemetryCommonPropertiesTests.cs left in tree.
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
hint: When you have resolved this problem, run "git am --continue".
hint: If you prefer to skip this patch, run "git am --skip" instead.
hint: To restore the original branch and stop patching, run "git am --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Patch failed at 0001 Add copilot-app LLM environment telemetry detection
Error: The process '/usr/bin/git' failed with exit code 128

Link to workflow output

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