Fix inherited agent detection in interactive terminals and expand agent detection - #9818
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
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 |
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 |
e658141 to
e42bbe2
Compare
Expand detection for supported coding-agent hosts and map them to bounded execution-environment telemetry values. Use actual terminal capabilities instead of inherited agent markers when deciding whether prompts and terminal output are available, while keeping non-terminal agent invocations in no-prompt mode. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
e42bbe2 to
246e14d
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
AZD_FORCE_TTY=true can incorrectly make a non-interactive agent invocation prompt-capable.
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 (1)
| Severity | Finding |
|---|---|
cli/azd/cmd/auto_install.go — terminal.IsTerminal honors AZD_FORCE_TTY, so a non-interactive agent process with… |
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 |
Use physical stdin and stdout attachment when deciding whether detected agent invocations can prompt. Keep AZD_FORCE_TTY limited to terminal-style rendering. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
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 |
Issues resolved since last review (1)
| Severity | Finding |
|---|---|
cli/azd/cmd/auto_install.go — terminal.IsTerminal honors AZD_FORCE_TTY, so a non-interactive agent process with… View resolved comment |
There was a problem hiding this comment.
Copilot review overview
🔵 Needs a closer look
The new telemetry data source requires the privacy review currently marked as unnecessary.
Review tier: Balanced
Findings: None
Issues resolved since last review (1)
| Severity | Finding |
|---|---|
cli/azd/pkg/azdext/tui.go — CanPrompt no longer excludes detected agents, but `cli/azd/docs/extensions/extension-sdk-reference… View resolved comment |
Suppressed comments (1)
Previously missed (1) — in code that hasn't changed since the last review.
cli/azd/internal/runcontext/agentdetect/detect_env.go:52
CODEX_INTERNAL_ORIGINATOR_OVERRIDEis a new data source for the emittedexecution.environmenttelemetry value. The enum-only exemption indocs/specs/metrics-audit/privacy-review-checklist.md:35-40does not apply when a new value captures a new source, while lines 23-25 require a privacy review for new sources. The PR currently marks that review as unnecessary; complete the privacy review and update the checklist before merge.
Azure Dev CLI Install InstructionsInstall scriptsMacOS/Linux
bash: pwsh: WindowsPowerShell install MSI install Standalone Binary
MSI
Documentationlearn.microsoft.com documentationtitle: Azure Developer CLI reference
|
Marina He (hemarina)
left a comment
There was a problem hiding this comment.
I reviewed the agent-detection and telemetry changes and did not find any blocking runtime, telemetry, or GDPR issues.
The updated markers appear correct: CLAUDECODE=1 and COPILOT_CLI are the actual subprocess markers, while the removed alternatives do not appear to be valid markers set by those agents. Using CLAUDE_CODE_ENTRYPOINT only to refine an already-detected Claude Code environment also avoids false attribution from inherited values.
The new execution.environment values are fixed, allowlisted enums and do not expose raw environment-variable values or user-derived content. The existing SystemMetadata classification and BusinessInsight purpose remain appropriate, and the telemetry schema, audit matrix, public reference, environment-variable documentation, and tests are consistent with the implementation.
|
/check-enforcer override |


Fixes #9815
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, 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.Privacy review completed for the new environment data sources.Not needed as we're using existing field and adding new enum values.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.