feat(core): detect VS Code Copilot as AI agent
Current Behavior
When running Nx commands from VS Code Copilot's chat panel, Nx does not detect that it's running inside an AI agent. This means the TUI is enabled, which doesn't work well with AI agents that expect plain text output.
Expected Behavior
Nx should detect when it's running from VS Code Copilot's chat panel and disable the TUI accordingly, similar to how it handles Claude Code, Cursor, and Repl.it.
Related Issue(s)
Fixes #33698
Implementation
Added detection for VS Code Copilot by checking if the PATH environment variable contains github.copilot-chat. When VS Code Copilot runs terminal commands, it adds its CLI tool path (e.g., .../globalStorage/github.copilot-chat/copilotCli) to the PATH.
Changes:
- Added
is_vscode_copilot()function to detect VS Code Copilot - Added
is_vscode_copilot_from_path()helper for testability - Updated
is_ai_agent()to include VS Code Copilot detection - Added unit tests for the new detection logic
Deploy request for nx-docs pending review.
Visit the deploys page to approve it
| Name | Link |
|---|---|
| Latest commit | 9e837192e96d738c17523ea8548727f3df584592 |
The latest updates on your projects. Learn more about Vercel for GitHub.
| Project | Deployment | Preview | Updated (UTC) |
|---|---|---|---|
| nx-dev | Preview | Dec 9, 2025 11:23am |
View your CI Pipeline Execution โ for commit cbbcf4fad2ad7529377e20d4bc0a7424c012fb1e
| Command | Status | Duration | Result |
|---|---|---|---|
nx affected --targets=lint,test,test-kt,build,e... |
โ Failed | 1h 39m 57s | View โ |
nx run-many -t check-imports check-lock-files c... |
โ Succeeded | 2m 37s | View โ |
nx-cloud record -- nx-cloud conformance:check |
โ Succeeded | 12s | View โ |
nx-cloud record -- nx format:check |
โ Succeeded | <1s | View โ |
nx-cloud record -- nx sync:check |
โ Succeeded | <1s | View โ |
โ๏ธ Nx Cloud last updated this comment at 2025-12-09 11:16:50 UTC
Thanks for catching that @MaxKless! You're right - I just verified and the github.copilot-chat path is present in the regular VS Code terminal as well, not just in Copilot agent mode.
I've checked the environment more thoroughly, and unfortunately there doesn't appear to be a unique environment variable that distinguishes Copilot agent mode from regular VS Code terminal usage:
GIT_PAGER=catis set, but this might also be common in regular VS Code- No
COPILOT_*or similar specific env vars are set - TTY status is the same in both cases (stdin/stdout/stderr all report as terminals)
- Parent process is the same VS Code helper
Do you have any suggestions for how we might detect Copilot agent mode specifically? Some possibilities:
- Is there perhaps a VS Code extension API that could set a specific env var when running from agent mode?
- Could Copilot itself set something like
GITHUB_COPILOT_AGENT=1when invoking terminal commands? - Should we file an issue with the Copilot team to request an environment variable for this use case?
Alternatively, would it make sense to approach this from a different angle - perhaps detecting that the terminal is not truly interactive in some way, even if it reports as a TTY?