Env exported in sessionStart hook does not persist across Cursor restarts

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

If you use the sessionStart hook to export env vars for the session to use but close out of cursor and resume the session later, the env vars are not present in the session in it’s resumed state.

Steps to Reproduce

Export an env var in sessionStart and use it in another hook such as preToolUse. Prompting the agent to use a tool will invoke preToolUse and the exported envvar will be in scope. Close cursor and resume the session. Prompting the agent to use a tool will invoke the preToolUse hook but the exported envvar will no longer be available to use.

Expected Behavior

The session is resumed and the previously exported env vars should still be available to the session.

Operating System

MacOS

Version Information

Version: 3.0.9 (Universal)
VSCode Version: 1.105.1
Commit: 93e276db8a03af947eafb2d10241e2de17806c20
Date: 2026-04-03T02:06:46.446Z
Layout: editor
Build Type: Stable
Release Track: Default
Electron: 39.8.1
Chromium: 142.0.7444.265
Node.js: 22.22.1
V8: 14.2.231.22-electron.0
OS: Darwin arm64 24.6.0

Does this stop you from using Cursor

No - Cursor works, but with this issue

Thanks for reporting this @bradcypert! I can reproduce this not only when restarting Cursor, but when just closing a chat and reopening it. It sounds closely related to SubAgents do not inherit environment variables, but I’ve filed a separate bug.

I’d assume this is related to what I reported about sessionStart not being called a second time. Closing/reopening the chat leads to the same behavior as reported here across restarts