What fixed it for me is creating a ~/.zshenv file:
# Source .zprofile for PATH setup (Homebrew, etc.)
# This file is sourced for all shells, including non-interactive ones
[ -f ~/.zprofile ] && source ~/.zprofile
# Define dump_zsh_state as a no-op to silence Cursor's shell integration errors
dump_zsh_state() { :; }
Non-interactive shells, which Cursor’s agents use, don’t source ~/.zprofile or ~/.zshrc, so they will be missing all the usual env variables. The dump_zsh_state redefine to a no-op seemed necessary because I think Cursor was trying to run that every time, but it’s not defined anywhere… So not sure if that’s mean to be something real or not. The thread on Zsh Terminal State is Not Persistent in AI Assistant Due to dump_zsh_state: command not found Error - #40 by andrewh seems to indicate it’s not.