fix: Recognize Copilot CLI#8249
Conversation
Fixes #8234. `azd` attempts to determine if it is being invoked by an AI agent (e.g. Claude, Gemini, Copilot, etc.) and alter its behavior to be more "AI friendly". This includes setting the --`no-prompt` parameter by default, and reducing the console output from spinners, progress bars, and the like. The most reliable way of doing this is by checking for certain environment variables set by the AI agent process. However, `azd` does not check for the variable currently used by Copilot CLI and VS Code: `COPILOT_CLI`. Here we add a check for this specific environment variable and update the tests accordingly.
📋 Prioritization NoteThanks for the contribution! The linked issue isn't in the current milestone yet. |
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates azd's AI-agent detection to recognize Copilot CLI/VS Code via the COPILOT_CLI environment variable, ensuring agent-friendly defaults (e.g., --no-prompt, reduced TTY UX) apply consistently.
Changes:
- Add
COPILOT_CLIto the known environment variable patterns for GitHub Copilot CLI detection. - Extend unit/integration tests to validate agent detection behavior when
COPILOT_CLIis present. - Ensure test helpers clear
COPILOT_CLIto avoid cross-test contamination.
Show a summary per file
| File | Description |
|---|---|
| cli/azd/internal/terminal/terminal_test.go | Adds TTY-disable test case for COPILOT_CLI and clears it in env cleanup helper. |
| cli/azd/internal/runcontext/agentdetect/detect_test.go | Adds detection test case for COPILOT_CLI and clears it in env cleanup helper. |
| cli/azd/internal/runcontext/agentdetect/detect_env.go | Adds COPILOT_CLI to Copilot env var detection patterns. |
| cli/azd/cmd/auto_install_test.go | Adds global flag parsing test to ensure --no-prompt auto-enables via COPILOT_CLI. |
| cli/azd/cmd/auto_install_integration_test.go | Adds integration test for COPILOT_CLI and clears it in env cleanup helper. |
Copilot's findings
- Files reviewed: 5/5 changed files
- Comments generated: 1
wbreza
left a comment
There was a problem hiding this comment.
Clean, surgical fix. Adds COPILOT_CLI to the agent-detection patterns with thorough parallel test coverage across detection, auto-install (unit + integration), and terminal TTY tests. Notably, all four env-var cleanup lists (clearAgentEnvVars, clearTestEnvVars, clearAgentEnvVarsForTest) are updated consistently — a detail that's commonly missed and would cause cross-test bleed. PR description aligns with the implementation and references the originating issue.
LGTM.
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Fixes #8234. `azd` attempts to determine if it is being invoked by an AI agent (e.g. Claude, Gemini, Copilot, etc.) and alter its behavior to be more "AI friendly". This includes setting the --`no-prompt` parameter by default, and reducing the console output from spinners, progress bars, and the like. The most reliable way of doing this is by checking for certain environment variables set by the AI agent process. However, `azd` does not check for the variable currently used by Copilot CLI and VS Code: `COPILOT_CLI`. Here we add a check for this specific environment variable and update the tests accordingly. Co-authored-by: therealjohn <1501196+therealjohn@users.noreply.github.com>
Fixes #8234.
azdattempts to determine if it is being invoked by an AI agent (e.g. Claude, Gemini, Copilot, etc.) and alter its behavior to be more "AI friendly". This includes setting the --no-promptparameter by default, and reducing the console output from spinners, progress bars, and the like.The most reliable way of doing this is by checking for certain environment variables set by the AI agent process. However,
azddoes not check for the variable currently used by Copilot CLI and VS Code:COPILOT_CLI.Here we add a check for this specific environment variable and update the tests accordingly.