Skip to content

Set COPILOT_AGENT env var in agent terminals - #316267

Merged
Megan Rogge (meganrogge) merged 1 commit into
mainfrom
merogge/agent-env-var
May 13, 2026
Merged

Megan Rogge (meganrogge) merged 1 commit into
mainfrom
merogge/agent-env-var

Conversation

@meganrogge

Copy link
Copy Markdown
Collaborator

Fixes #311734

Sets COPILOT_AGENT=1 in agent terminal sessions so CLI tools can detect they are running inside an AI agent and adapt their output (e.g. JSON instead of ANSI, disable interactive prompts, skip animations).

This follows the same pattern as other agents:

Agent Environment Variable
Claude Code CLAUDE_CODE
Cursor CURSOR_AGENT
Codex CODEX_SANDBOX
Gemini CLI GEMINI_CLI
VS Code Copilot COPILOT_AGENT

Changes

  • toolTerminalCreator.ts: Added COPILOT_AGENT: '1' to the env vars set when creating agent terminals

Fixes #311734

Set COPILOT_AGENT=1 in agent terminal sessions so CLI tools can
detect they are running inside an AI agent and adapt their output
(e.g. JSON instead of ANSI, disable interactive prompts, skip
animations). This follows the same pattern as other agents
(CLAUDE_CODE, CURSOR_AGENT, etc.).

Co-authored-by: Copilot <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Sets a Copilot-specific environment marker for agent-created terminal sessions so child CLI tools can detect they are running under VS Code Copilot agent execution.

Changes:

  • Adds COPILOT_AGENT: '1' to the environment passed to agent terminal creation.
  • Documents the intent and links the associated feature request.
Show a summary per file
File Description
src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/toolTerminalCreator.ts Adds the COPILOT_AGENT environment variable alongside existing agent terminal Git-related environment defaults.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@meganrogge
Megan Rogge (meganrogge) merged commit 5060335 into main May 13, 2026
29 checks passed
@meganrogge
Megan Rogge (meganrogge) deleted the merogge/agent-env-var branch May 13, 2026 17:01
Nikola Hristov (NikolaRHristov) pushed a commit to DependencyCodeEditorLand/Editor that referenced this pull request May 13, 2026
Fixes microsoft#311734

Set COPILOT_AGENT=1 in agent terminal sessions so CLI tools can
detect they are running inside an AI agent and adapt their output
(e.g. JSON instead of ANSI, disable interactive prompts, skip
animations). This follows the same pattern as other agents
(CLAUDE_CODE, CURSOR_AGENT, etc.).

Co-authored-by: Megan Rogge <[email protected]>
Co-authored-by: Copilot <[email protected]>
@vs-code-engineering vs-code-engineering Bot locked and limited conversation to collaborators Jun 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants