Add AGENT=1 Environment Variable for Composer Runs

When running commands through Cursor’s AI Composer, there’s no automatic way to detect if the command is being run by the AI assistant or by a human. This makes it difficult to:

  • Format test output differently for AI-assisted runs
  • Adjust logging verbosity automatically
  • Apply different configuration based on the execution context

Currently, users must manually set environment variables (like HUMAN=1 or via some other mechanism) to achieve this differentiation.

Proposed Solution

Add an automatic environment variable (e.g., AGENT=1, CURSOR_AGENT=1 or CURSOR_COMPOSER=1) when executing commands through the AI Composer.

Example Usage

if os.Getenv("AGENT") == "1" {
    // Use more verbose or specific test output
    t.Logf("Detailed context: %+v", testData)
} else {
    // Use concise output for human runs
    t.Log("Test passed")
}

Benefits

  1. Easier differentiation between AI-assisted and human-run commands
  2. Automatic context-aware logging and output formatting
  3. Better debugging experience when working with the AI assistant

Implementation Notes

  • The variable should be consistently set for all Composer-executed commands
  • Consider making the variable name configurable in Cursor settings
  • Potential for additional context variables (e.g., CURSOR_SESSION_ID)

Related Use Cases

  • Test output formatting
  • Debug logging levels
  • Configuration management
  • CI/CD pipeline differentiation

This is a really good suggestion, I hope it gets some attention.

it would be nice if I could find a way to simply set an environment variable that would be inherited by the agent terminal, it doesn’t inherit any of the integrated terminal settings, it doesn’t use the automationProfile settings, I’m going crazy trying to find a way to get agent terminals to respect custom shell settings of any kind

I get that there’s thousands of things want to implement, but I find it kinda baffling that there does not seem to be any way to control the runtime environment of the agent at all.

Is the only workaround really to control the runtime environment of all shells in vscode?

Happened upon a potential (not the best) work around today by accident. Inside the agent the PAGER env var is set to head -n 10000 | cat which is different from my integrated and other terminal envs which are set to less. There is also a COMPOSER_NO_INTERACTION=1 env var that is set in some cases, not sure how often it is used though.

Not a good long term or stable solution but at least some work-around for now until this gets enough attention.

I am on macOS, not sure if other systems are different.

Also to check I just ran env > ./environment_variables_user.txt myself and got the agent to run env > ./.logz/environment_variables_agent.txt and make a diff of the two files.