feat(core): add vendor-neutral AGENT=gemini environment variable#21032
feat(core): add vendor-neutral AGENT=gemini environment variable#21032sw-square wants to merge 2 commits intogoogle-gemini:mainfrom
Conversation
Add AGENT=gemini environment variable to all child processes spawned by Gemini CLI, alongside the existing GEMINI_CLI=1. This provides a vendor-neutral way for downstream tools to detect they are being executed by an AI agent. The AGENT env var is set in all three process spawning paths: - child_process.spawn (fallback shell execution) - PTY spawn (primary interactive shell execution) - MCP stdio transport (MCP server child processes) Relates to google-gemini#17079
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Gemini CLI by introducing a standardized, vendor-neutral Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a vendor-neutral AGENT=gemini environment variable to child processes, which is a good step towards standardization for AI agent detection. The changes are applied consistently across PTY, child_process, and MCP transports, and the tests are updated accordingly. I've found one minor area for improvement regarding code consistency in shellExecutionService.ts.
Address review feedback: replace hardcoded GEMINI_CLI: '1' with the exported constants for consistency with the child_process and MCP transport paths.
|
Hi there! Thank you for your interest in contributing to Gemini CLI. To ensure we maintain high code quality and focus on our prioritized roadmap, we have updated our contribution policy (see Discussion #17383). We only guarantee review and consideration of pull requests for issues that are explicitly labeled as 'help wanted'. All other community pull requests are subject to closure after 14 days if they do not align with our current focus areas. For this reason, we strongly recommend that contributors only submit pull requests against issues explicitly labeled as 'help-wanted'. This pull request is being closed as it has been open for 14 days without a 'help wanted' designation. We encourage you to find and contribute to existing 'help wanted' issues in our backlog! Thank you for your understanding and for being part of our community! |
Summary
Add a vendor-neutral
AGENT=geminienvironment variable to all child processes spawned by Gemini CLI, alongside the existingGEMINI_CLI=1.This allows downstream tools to detect they are being executed by an AI agent using a single, standardized variable — without needing to check for each agent's tool-specific variable (
GEMINI_CLI,CLAUDECODE,CODEX_SANDBOX,CURSOR_AGENT, etc.).Details
Key Changes
AGENT_IDENTIFICATION_ENV_VAR(AGENT) andAGENT_IDENTIFICATION_ENV_VAR_VALUE(gemini) inshellExecutionService.tsAGENT=geminiin all three child process spawning paths:Why a standard
AGENTvariable?Every AI coding agent currently sets its own env var:
GEMINI_CLI1CLAUDECODE1CODEX_SANDBOXseatbeltCURSOR_AGENT1GOOSE_TERMINAL1This forces every downstream tool to maintain a detection matrix. A shared
AGENTvariable (analogous toCI=true) lets tools write one check:The value (
gemini) identifies which agent is running, enabling agent-specific behavior when needed.Adoption
Goose (PR #7017) and Amp already ship
AGENT=<name>. Consumer-side detection is already happening in Bun and Vercel.See the standardization discussion at agentsmd/agents.md#136.
Related Issues
Relates to #17079
How to Validate
npm startecho $AGENTgemininpx vitest run packages/core/src/services/shellExecutionService.test.tsPre-Merge Checklist