Agent Terminal Integration Sends Stray 'q' Characters

Describe the Bug

When using Cursor’s AI agent to run terminal commands, the agent system sends a stray ‘q’ character to the terminal after command completion, resulting in the error: zsh: command not found: q. This frequently results in cursor hanging waiting for output, and not proceeding with work.

Steps to Reproduce

  1. Open Cursor with a project that has a terminal
  2. Use the AI agent to run terminal commands (e.g., ls, echo "test", etc.)
  3. After command completion, observe the error: zsh: command not found: q

Expected Behavior

Agent terminal commands should execute cleanly without sending stray characters to the shell.

Operating System

Windows 10/11

Current Cursor Version (Menu → About Cursor → Copy)

  • OS: Linux (WSL2) - Ubuntu
  • Cursor Version: 1.2.4 (from TERM_PROGRAM_VERSION)
  • Shell: zsh 5.8.1
  • Terminal: xterm-256color
  • Environment: WSL2 on Windows

Additional Information

Additional Context

  • This issue only occurs when the AI agent runs commands, not when users interact with the terminal directly
  • The issue persists regardless of shell configuration (tested with minimal zsh config)
  • The ‘q’ character appears to be sent by Cursor’s agent terminal integration system
  • This is not a user shell configuration issue, as it doesn’t occur during normal terminal usage

Impact

  • Creates noise in terminal output
  • May interfere with automated scripts or CI/CD processes
  • Reduces the reliability of agent-executed terminal commands

Workarounds Attempted

  • Various shell configurations (minimal vs full zsh setup)
  • Different terminal profiles
  • Environment variable modifications
  • Shell aliases (temporary workaround by aliasing ‘q’ to ‘:’)

Request

Please investigate the agent terminal integration system to identify why stray ‘q’ characters are being sent to the terminal after command execution.

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Additionally, here’s an updated .zshrc file that cursor tried to create to help with the issues, but it didn’t work reliably:

# Smart zsh configuration that detects agent vs user usage

# Check if this is likely an agent interaction
# For now, let's use a simple environment variable approach
if [[ "$AGENT_MODE" == "1" ]] || [[ "$CURSOR_AGENT" == "1" ]]; then

    # AGENT MODE - Minimal configuration for speed
    export PATH="$HOME/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH"

    # Disable slow features
    export HOMEBREW_NO_AUTO_UPDATE=1
    export HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1
    export STARSHIP_CONFIG=""
    export KUBECONFIG=""

    # Simple aliases
    alias ls="ls --color=auto"
    alias ll="ls -la"
    alias la="ls -A"

    # Fix for Cursor agent stray 'q' character
    alias q=':'

    # Simple prompt
    export PS1='%n@%m:%~$ '

    # Disable completion
    skip_global_compinit=1

    # Set agent flag for future reference
    export AGENT_MODE=1

else
    # USER MODE - Full configuration
    export ZSH="$HOME/.oh-my-zsh"

    ZSH_THEME="robbyrussell"

    plugins=(git zsh-autosuggestions zsh-syntax-highlighting fzf asdf)

    source $ZSH/oh-my-zsh.sh

    eval "$(starship init zsh)"

    [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh

    # tabtab source for packages
    # uninstall by removing these lines
    [[ -f ~/.config/tabtab/zsh/__tabtab.zsh ]] && . ~/.config/tabtab/zsh/__tabtab.zsh || true
    autoload -Uz compinit && compinit -i
    alias bat="batcat"
    alias relaylink="node ~/projects/eve/relay-link/index.js"

    source <(/home/linuxbrew/.linuxbrew/bin/kubectl completion zsh)

    eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"

    PATH=~/.console-ninja/.bin:$PATH
    PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
    PATH="${ASDF_DATA_DIR:-$HOME/.asdf}/shims:$PATH"
    # ---- Eza (better ls) -----

    alias ls="eza --icons=always"

    # --- Zoxide (better CD) ---
    alias cd="z"
    eval "$(zoxide init zsh)"

    # Created by `pipx` on 2024-07-17 19:13:40
    export PATH="$PATH:/home/mckernanin/.local/bin"
fi

@deanrie @danperks @T1000

This has been reported hundreds of times.

Please tell me someone is looking into it!

Hi @mwjt42 yes Cursor team is working on that and has an improvement prepared. It will be released soon with other improvements.

Thank you for tagging me!

1 Like

Fab stuff, thanks for the quick reply.

Looking forward to the new release

1 Like