Skip to content

Feature Request: Set an environment variable (e.g. COPILOT_AGENT) when agent/subagent runs a terminal command #311734

Closed

Description

Problem

When VS Code Copilot Chat (or its subagents) executes a command in the terminal via tools like run_in_terminal or execution_subagent, there is no way for CLI tools to detect that the command was initiated by an AI agent rather than a human user.

Other AI coding agents already set environment variables in spawned subprocesses:

Agent Environment Variable(s)
Claude Code CLI CLAUDECODE, CLAUDE_CODE
Cursor CURSOR_AGENT
Codex CODEX_SANDBOX, CODEX_THREAD_ID
Gemini CLI GEMINI_CLI
Augment AUGMENT_AGENT
Opencode OPENCODE_CLIENT, OPENCODE
AMP AMP_CURRENT_THREAD_ID
Antigravity ANTIGRAVITY_AGENT

There is also a generic convention (AI_AGENT) used by tools like shipfastlabs/agent-detector and discussed in agentsmd/agents.md#136.

Proposal

When Copilot Chat (or a subagent) runs a command in the terminal, set an environment variable such as:

COPILOT_AGENT=1

or follow the generic convention:

AI_AGENT=copilot

This would allow CLI tools to:

  • Output machine-readable formats (JSON) instead of ANSI-decorated human-readable text, reducing token usage and improving parsing accuracy
  • Disable interactive prompts that would otherwise block the agent
  • Skip animations and progress bars that add noise to agent output

Context

The VS Code core team closed microsoft/vscode#258911 arguing that agent terminals should behave like user terminals. However, this is a different request — it is not about changing terminal behavior but about giving programs the ability to optimize their output format when they know an agent is consuming it. The terminal itself stays the same; the program running inside it adapts.

This is analogous to how CI=true allows programs to detect CI/CD environments and adjust behavior accordingly (disable interactive prompts, simplify output, etc.). The same pattern is valuable for AI agent environments.

Real-world use case

The Bootgly PHP Framework test runner (bootgly test) detects AI agents via environment variables and outputs compact JSON instead of ANSI-formatted text when an agent is detected. This dramatically improves the agent's ability to parse test results accurately. However, Copilot Chat currently cannot be detected because it does not set any identifying environment variable when running terminal commands.

Activity

  1. sdairs commented on May 4, 2026

    @sdairs

    +1 but more harnesses have adopted AGENT than AI_AGENT, so that would be preferable.

  2. molisani commented on May 4, 2026

    @molisani

    +1 but more harnesses have adopted AGENT than AI_AGENT, so that would be preferable.

    There is also a generic convention (AI_AGENT) ... discussed in agentsmd/agents.md#136.

    The proposal referenced seems to be the main focal point of the effort to standardize this environment variable, and it now proposes AGENT rather than AI_AGENT.

  3. added
    feature-request
    chat-terminal
    on May 6, 2026
  4. vs-code-engineering commented on May 6, 2026

    @vs-code-engineering
    Contributor

    This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

    Happy Coding!

  5. vs-code-engineering commented on May 8, 2026

    @vs-code-engineering
    Contributor

    🙂 This feature request received a sufficient number of community upvotes and we moved it to our backlog. To learn more about how we handle feature requests, please see our documentation.

    Happy Coding!

  6. added a commit that references this issue on May 13, 2026
    5060335
  7. added
    unreleased
    on May 13, 2026
  8. added a commit that references this issue on May 13, 2026
    a5876cc
  9. added
    insiders-released
    verification-needed
    and removed
    unreleased
    on May 14, 2026
  10. locked and limited conversation to collaborators on Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

chat-terminalfeature-requestinsiders-releasedverification-neededverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions