Skip to content

fix: distinguish GitHub Copilot App execution environment - #9288

Merged
vhvb1989 merged 1 commit into
Azure:mainfrom
qinezh:qinezh/fix-copilot-app-execution-environment
Jul 24, 2026
Merged

fix: distinguish GitHub Copilot App execution environment#9288
vhvb1989 merged 1 commit into
Azure:mainfrom
qinezh:qinezh/fix-copilot-app-execution-environment

Conversation

@qinezh

@qinezh qinezh commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Summary

  • detect the GitHub Copilot App from the exact AI_AGENT=github_copilot_app_agent marker before Copilot CLI fallback markers
  • report GitHub Copilot App through execution.environment
  • add precedence coverage and isolate tests from the ambient AI_AGENT variable

Testing

  • go test ./internal/runcontext/agentdetect ./internal/tracing/resource ./internal/terminal
  • go test ./cmd -run '^(TestParseGlobalFlags_AgentDetection|TestAgentDetectionIntegration)$'

Fixes #9289

Detect the Copilot App-specific AI_AGENT value before Copilot CLI markers so execution.environment reports the correct caller. Add precedence coverage and keep agent test environments isolated.
Copilot AI review requested due to automatic review settings July 24, 2026 03:43
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
7 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

Adds distinct GitHub Copilot App detection and telemetry reporting.

Changes:

  • Detects the exact AI_AGENT marker with CLI-marker precedence.
  • Adds agent and telemetry environment constants.
  • Expands detection coverage and test isolation.

Reviewed changes

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

Show a summary per file
File Description
docs/reference/telemetry-data.md Documents the telemetry value.
cli/azd/internal/tracing/resource/exec_environment.go Maps the detected app to telemetry.
cli/azd/internal/tracing/fields/fields.go Defines the telemetry value.
cli/azd/internal/terminal/terminal_test.go Clears ambient AI_AGENT.
cli/azd/internal/runcontext/agentdetect/types.go Defines the app agent type.
cli/azd/internal/runcontext/agentdetect/detect_test.go Tests detection and precedence.
cli/azd/internal/runcontext/agentdetect/detect_env.go Detects the exact app marker.
cli/azd/cmd/auto_install_integration_test.go Isolates integration tests from AI_AGENT.

Comment thread cli/azd/internal/runcontext/agentdetect/detect_env.go
Comment thread cli/azd/internal/tracing/fields/fields.go
Comment thread cli/azd/internal/tracing/resource/exec_environment.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.

Reviewed the change. The exact AI_AGENT=github_copilot_app_agent match is gated ahead of the Copilot CLI markers and wired through both DisplayName and execEnvFromAgent. Precedence and the unrecognized-value case are covered by the new tests, and the targeted suites pass locally (agentdetect, tracing/resource, terminal, and the cmd agent-detection tests).

The three open automated-review comments look non-blocking:

  • environment-variables.md: existing host-detection markers like COPILOT_CLI and CLAUDE_CODE aren't listed there either, so omitting AI_AGENT stays consistent with the current convention.
  • telemetry-schema.md: it documents fields, not the execution.environment value list. That enumeration lives in telemetry-data.md, which this PR updates.
  • resource-level test: there's no per-agent execEnvFromAgent test today, and the behavior being fixed is the detection precedence, which is already covered.

@JeffreyCA JeffreyCA 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.

Thank you, looks good!

@JeffreyCA

Copy link
Copy Markdown
Contributor

/check-enforcer evaluate

@vhvb1989
vhvb1989 merged commit be795f5 into Azure:main Jul 24, 2026
15 of 16 checks passed
@qinezh
qinezh deleted the qinezh/fix-copilot-app-execution-environment branch July 28, 2026 01:56
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.

[Issue] GitHub Copilot App is reported as Copilot CLI in execution.environment

5 participants