Fix inherited agent detection in interactive terminals and expand agent detection - #9818
Fix inherited agent detection in interactive terminals and expand agent detection#9818JeffreyCA wants to merge 3 commits into
Conversation
|
Azure Pipelines: Successfully started running 1 pipeline(s). 21 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Telemetry synchronization and user-facing help require updates before merge.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 3
New issues introduced by this change (3)
| Severity | Finding |
|---|---|
cli/azd/cmd/auto_install.go — The new behavior exempts interactive terminals, but the public --no-prompt help still says every… |
|
cli/azd/pkg/azdext/tui.go — GITHUB_COPILOT is not one of the markers this detector reads, so this public field comment… |
|
docs/specs/metrics-audit/telemetry-schema.md — Expanding this enum changes the raw telemetry value set, but feature-telemetry-matrix.md is not… |
What changed in this PR
Updates agent detection so inherited markers do not disable prompts in interactive terminals, while expanding host-specific telemetry attribution.
Changes:
- Gates automatic no-prompt mode on terminal capabilities.
- Adds/refines agent markers and bounded telemetry values.
- Expands unit and integration coverage and documentation.
| File | Description |
|---|---|
docs/specs/metrics-audit/telemetry-schema.md |
Expands execution-environment values. |
docs/reference/telemetry-data.md |
Documents new agent environments. |
cli/azd/pkg/azdext/tui.go |
Updates extension interactivity detection. |
cli/azd/pkg/azdext/tui_test.go |
Tests extension agent handling. |
cli/azd/internal/tracing/resource/resource_test.go |
Tests telemetry attribution. |
cli/azd/internal/tracing/resource/exec_environment.go |
Maps new agent types. |
cli/azd/internal/tracing/fields/fields.go |
Defines bounded environment values. |
cli/azd/internal/terminal/terminal.go |
Removes agent-based TTY suppression. |
cli/azd/internal/terminal/terminal_test.go |
Tests terminal override behavior. |
cli/azd/internal/runcontext/agentdetect/types.go |
Adds agent types and names. |
cli/azd/internal/runcontext/agentdetect/detect.go |
Clarifies detection semantics. |
cli/azd/internal/runcontext/agentdetect/detect_test.go |
Expands detection coverage. |
cli/azd/internal/runcontext/agentdetect/detect_env.go |
Refines exact environment matching. |
cli/azd/docs/environment-variables.md |
Documents markers and prompt behavior. |
cli/azd/cmd/middleware/extensions.go |
Clarifies no-prompt propagation. |
cli/azd/cmd/init.go |
Uses terminal capability for directory behavior. |
cli/azd/cmd/init_test.go |
Updates initialization fixtures. |
cli/azd/cmd/auto_install.go |
Gates agent no-prompt behavior on TTY state. |
cli/azd/cmd/auto_install_test.go |
Tests global flag behavior. |
cli/azd/cmd/auto_install_integration_test.go |
Tests integrated agent detection. |
cli/azd/.vscode/cspell.yaml |
Allows the corrected Claude marker. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
35a463d to
14d8012
Compare
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
14d8012 to
5f9f4a7
Compare
|
Azure Pipelines: Successfully started running 1 pipeline(s). 21 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The regression test bypasses the changed TTY path, and the public extension SDK reference remains stale.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Review tier: Balanced
Findings: 1
New issues introduced by this change (2)
| Severity | Finding |
|---|---|
cli/azd/internal/terminal/terminal_test.go — AZD_FORCE_TTY=true returns before the agent check in both the old and new IsTerminal… |
|
cli/azd/pkg/azdext/tui.go — CanPrompt no longer excludes detected agents, but `cli/azd/docs/extensions/extension-sdk-reference… |
Issues resolved since last review (3)
| Severity | Finding |
|---|---|
docs/specs/metrics-audit/telemetry-schema.md — Expanding this enum changes the raw telemetry value set, but feature-telemetry-matrix.md is not… View resolved comment |
|
cli/azd/pkg/azdext/tui.go — GITHUB_COPILOT is not one of the markers this detector reads, so this public field comment… View resolved comment |
|
cli/azd/cmd/auto_install.go — The new behavior exempts interactive terminals, but the public --no-prompt help still says every… View resolved comment |
| func (i InteractiveInfo) CanPrompt() bool { | ||
| return i.StdinTTY && i.StdoutTTY && !i.NoPrompt && !i.CI && !i.Agent | ||
| return i.StdinTTY && i.StdoutTTY && !i.NoPrompt && !i.CI |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
Antigravity detection omits its native marker in both core and extension paths.
Review tier: Balanced
Findings: 1
Pre-existing issues (1)
| Severity | Finding |
|---|---|
cli/azd/pkg/azdext/tui.go — CanPrompt no longer excludes detected agents, but `cli/azd/docs/extensions/extension-sdk-reference… View comment |
Issues resolved since last review (1)
| Severity | Finding |
|---|---|
cli/azd/internal/terminal/terminal_test.go — AZD_FORCE_TTY=true returns before the agent check in both the old and new IsTerminal… View resolved comment |
Suppressed comments (2)
Previously missed (2) — in code that hasn't changed since the last review.
cli/azd/internal/runcontext/agentdetect/detect_env.go:42
- This misses Antigravity's native
ANTIGRAVITY_AGENTmarker, which current integrations such as Google-ownedfirebase-toolsand Vercel's agent detector use. An Antigravity invocation that only exposes its native marker therefore falls through, so no-prompt behavior andexecution.environmentattribution are not applied. Add the native marker with its verified boolean values, then synchronize the SDK detector, tests, and environment-variable reference.
cli/azd/pkg/azdext/tui.go:170 - The extension detector repeats the core omission of Antigravity's native
ANTIGRAVITY_AGENTmarker. Extensions running directly under Antigravity will reportAgent=falsewhen only that native marker is present, despite the new Antigravity support. Keep this marker set synchronized withinternal/runcontext/agentdetect.
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The code is coherent, but required privacy and downstream telemetry reviews remain incomplete.
Review tier: Balanced
Findings: 1
Pre-existing issues (1)
| Severity | Finding |
|---|---|
cli/azd/pkg/azdext/tui.go — CanPrompt no longer excludes detected agents, but `cli/azd/docs/extensions/extension-sdk-reference… View comment |
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 #9815
Related to #9578
This PR keeps
azdinteractive when a user runs it from a real terminal that inherited coding-agent environment variables. It also tightens agent attribution and adds bounded telemetry values for Claude Code Desktop, Claude Code in VS Code, Codex Desktop, GitHub Copilot cloud agent, Antigravity CLI, and Pi.Issue
Coding agents can launch VS Code or another terminal host from shell mode. The new process inherits agent markers, causing commands typed by the user in an integrated terminal to be treated as non-interactive agent execution.
Agent attribution also lacked distinct values for several supported hosts, while some detected environment variables were not valid markers.
Changes
Telemetry change checklist
New fields and events
execution.environmentenum.Privacy
execution.environmentremains classified asSystemMetadataforBusinessInsight.Testing
Downstream
Documentation
Testing
Tests cover non-interactive agent commands, interactive terminals with inherited markers, exact marker matching, host-specific fallback behaviour, detection precedence, and each new
execution.environmentvalue.