Skip to content

feat: add AGENT=goose environment variable for cross-tool compatibility#7017

Merged
dianed-square merged 2 commits intoblock:mainfrom
sw-square:swesterman-goose.2026-02-05.add-agent-env-var
Feb 10, 2026
Merged

feat: add AGENT=goose environment variable for cross-tool compatibility#7017
dianed-square merged 2 commits intoblock:mainfrom
sw-square:swesterman-goose.2026-02-05.add-agent-env-var

Conversation

@sw-square
Copy link
Contributor

@sw-square sw-square commented Feb 6, 2026

Summary

This PR adds a generic AGENT=goose environment variable that is set alongside GOOSE_TERMINAL=1 in all shell command executions.

Motivation

There's quite a bit of setup in my configuration files that I don't want AI agents to use. It's quite annoying having to check for each individual agent's environment variables:

# ~/.zshrc
if [[  $CLAUDECODE != 1 && $GOOSE_TERMINAL != 1 && $AGENT != amp ]] then
	# setup non-agent stuff that can take awhile
	PS1= # ... setup PS1
	bindkey # ... custom keybinds for terminal
	source /.../zsh-syntax-highlighting.zsh # syntax highlighting and autosuggestions
	source /.../zsh-autosuggestions.zsh
	# modify path to include interactive scripts I don't want agents to use
	path+=( ~/_bin )
fi

I noticed that amp uses AGENT=amp, and I figured that's a good environment variable name to standardize on. This PR adds that in.

Note that this complements the GOOSE_TERMINAL=1 environment variable; it might be nice to eventually remove GOOSE_TERMINAL if AGENT becomes standardized.

Set AGENT=goose alongside GOOSE_TERMINAL=1 in all shell command executions.
This enables scripts and tools to detect AI agent execution without hardcoding
specific agent names.

The AGENT variable is set in developer extension, retry manager, computer
controller, and CLI update commands. Documentation updated with usage examples.
@sw-square sw-square marked this pull request as ready for review February 6, 2026 01:20
@sw-square sw-square requested a review from a team as a code owner February 6, 2026 01:20
Copilot AI review requested due to automatic review settings February 6, 2026 01:20
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a generic AGENT=goose environment variable to complement the existing GOOSE_TERMINAL=1 variable for better cross-tool compatibility. This enables users to write shell configuration that works across multiple AI agents without hardcoding agent-specific checks, following a pattern established by other agents like amp.

Changes:

  • Added AGENT=goose environment variable to all shell command executions alongside GOOSE_TERMINAL=1
  • Updated documentation to explain the new variable's purpose and provide usage examples
  • Maintains backward compatibility with existing GOOSE_TERMINAL checks

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
documentation/docs/guides/environment-variables.md Documents the new AGENT variable with clear examples and use cases
crates/goose/src/agents/retry.rs Adds AGENT=goose to shell command execution for both Windows (cmd) and Unix (sh)
crates/goose-mcp/src/developer/shell.rs Adds AGENT=goose to the shell command configuration
crates/goose-mcp/src/computercontroller/platform/windows.rs Adds AGENT=goose to Windows PowerShell automation commands
crates/goose-mcp/src/computercontroller/mod.rs Adds AGENT=goose to both PowerShell and Unix shell executions
crates/goose-cli/src/commands/update.rs Adds AGENT=goose to the update script execution

Documentation will be added back when the feature is released.
@dianed-square dianed-square added this pull request to the merge queue Feb 10, 2026
Merged via the queue into block:main with commit 1168d7d Feb 10, 2026
19 checks passed
@sw-square sw-square deleted the swesterman-goose.2026-02-05.add-agent-env-var branch February 10, 2026 17:38
tlongwell-block added a commit that referenced this pull request Feb 10, 2026
* origin/main:
  feat: add AGENT=goose environment variable for cross-tool compatibility (#7017)
  fix: strip empty extensions array when deeplink also (#7096)
  [docs] update authors.yaml file (#7114)
  Implement manpage generation for goose-cli (#6980)
  docs: tool output optimization (#7109)
  Fix duplicated output in Code Mode by filtering content by audience (#7117)
  Enable tom (Top Of Mind) platform extension by default (#7111)
  chore: added notification for canary build failure (#7106)
  fix: fix windows bundle random failure and optimise canary build (#7105)
  feat(acp): add model selection support for session/new and session/set_model (#7112)
  fix: isolate claude-code sessions via stream-json session_id (#7108)
  ci: enable agentic provider live tests (claude-code, codex, gemini-cli) (#7088)
  docs: codex subscription support (#7104)
  chore: add a new scenario (#7107)
  fix: Goose Desktop missing Calendar and Reminders entitlements (#7100)
  Fix 'Edit In Place' and 'Fork Session' features (#6970)
  Fix: Only send command content to command injection classifier (excluding part of tool call dict) (#7082)

# Conflicts:
#	crates/goose/src/agents/extension.rs
jh-block added a commit that referenced this pull request Feb 10, 2026
* origin/main: (30 commits)
  docs: GCP Vertex AI org policy filtering & update OnboardingProviderSetup component (#7125)
  feat: replace subagent and skills with unified summon extension (#6964)
  feat: add AGENT=goose environment variable for cross-tool compatibility (#7017)
  fix: strip empty extensions array when deeplink also (#7096)
  [docs] update authors.yaml file (#7114)
  Implement manpage generation for goose-cli (#6980)
  docs: tool output optimization (#7109)
  Fix duplicated output in Code Mode by filtering content by audience (#7117)
  Enable tom (Top Of Mind) platform extension by default (#7111)
  chore: added notification for canary build failure (#7106)
  fix: fix windows bundle random failure and optimise canary build (#7105)
  feat(acp): add model selection support for session/new and session/set_model (#7112)
  fix: isolate claude-code sessions via stream-json session_id (#7108)
  ci: enable agentic provider live tests (claude-code, codex, gemini-cli) (#7088)
  docs: codex subscription support (#7104)
  chore: add a new scenario (#7107)
  fix: Goose Desktop missing Calendar and Reminders entitlements (#7100)
  Fix 'Edit In Place' and 'Fork Session' features (#6970)
  Fix: Only send command content to command injection classifier (excluding part of tool call dict) (#7082)
  Docs: require auth optional for custom providers (#7098)
  ...
Tyler-Hardin pushed a commit to Tyler-Hardin/goose that referenced this pull request Feb 11, 2026
Tyler-Hardin pushed a commit to Tyler-Hardin/goose that referenced this pull request Feb 11, 2026
Tyler-Hardin pushed a commit to Tyler-Hardin/goose that referenced this pull request Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants