Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
sessionStart hooks that return valid JSON {"additional_context":"..."} are executed and merged successfully (Hooks output shows Merged 1 valid response(s) for step sessionStart), but the injected context often does not reach the agent’s initial system context — especially on the first message of a new Agent chat.
This is the same confirmed race previously acknowledged by Cursor staff (composer handle timing). The older reports are auto-closed, so I’m filing a fresh report with current Windows / Glass / 3.14.7 evidence.
Related (closed) threads:
- sessionStart hook additional_context is never injected into agent's initial system context
- sessionStart hook output is accepted and merged, but the injected context does not reach Agent Window
Staff diagnosis there (still accurate): additional_context is applied via the composer handle; sessionStart runs async before the handle is ready → silent drop. env from the same hook is more reliable because it does not need that handle.
Steps to Reproduce
- Create
~/.cursor/hooks/repro-sessionstart-marker.cmdwith this exact content:
@echo off
echo {"additional_context":"CURSOR_HOOK_REPRO_MARKER_8F3A2B1C"}
- Create or replace
~/.cursor/hooks.jsonwith:
{
"version": 1,
"hooks": {
"sessionStart": [
{
"command": "C:/Users/<YOU>/.cursor/hooks/repro-sessionstart-marker.cmd",
"timeout": 15
}
]
}
}
- Fully restart Cursor. Open Output → Hooks. Confirm the user
sessionStarthook is loaded. - Start a brand new Agent chat (Glass UI).
- Immediately send:
What is the value of CURSOR_HOOK_REPRO_MARKER_8F3A2B1C in your context?
- Optionally repeat: wait until Hooks shows
Merged 1 valid response(s), then send the same question in a new chat.
Expected Behavior
Per Hooks docs, additional_context from sessionStart should be in the conversation’s initial system context for the first turn, reliably, without requiring the user to delay the first message.
Actual Behavior
- Hooks channel: hook runs, valid JSON with
additional_context, thenMerged 1 valid response(s) for step sessionStart— no parse error. - Agent often has no knowledge of the marker / answers as if context was absent (e.g.
ponginstead of canary). - Failure is intermittent: more likely if the first message is sent quickly; waiting a few seconds after chat open sometimes works.
- There appear to be two races:
- Hook finishes before composer handle exists →
getHandleIfLoadedempty → silent drop (staff’s original report). - First user message is sent before
updateComposer(..., { hooksAdditionalContext })completes → first request lacksRequestContext.hooks_additional_contexteven when merge later succeeds.
- Hook finishes before composer handle exists →
Local inspection of workbench.glass.main.js (Glass) matches this: sessionStart is started in a fire-and-forget async IIFE; appendComposer creates the handle; apply uses getHandleIfLoaded(sessionId) then updateComposer — no await of the hook before create, and no retry/queue by session id for late apply.
Operating System
Windows 10/11
Version Information
- Version: 3.14.7 (stable)
- VS Code / Extension API: 1.128.0
- Commit: a758f2241ca99fecf380180b6cbdbbce0f1f42c0
- Date: 2026-07-30
- Layout: glass (
workbench.glass.main.js) - OS: Windows_NT x64
(Please ask if you need the full Help → About Electron/Chromium block.)
Additional Information
- Reproduced with a single native user
sessionStarthook (Claude/Third-Party imported hooks disabled), so this is not caused by non-JSON Claude SessionStart imports. - When Third Party / Claude hooks are imported, Cursor may run many extra SessionStart commands that fail
Failed to parse hook stdout as JSON; the one valid JSON hook still “Merges 1”, but slow sessionStart makes race (2) worse. sessionStartenvremains comparatively reliable (as previously noted by staff).- Workaround today: static User Rules / project
.cursor/rules— not suitable for dynamic session bootstrap (e.g. fetch live rules from an MCP/HTTP source at session start).
Happy to attach Hooks log excerpts or a Request ID from a failing canary turn if useful.
Does this stop you from using Cursor
No - Cursor works, but with this issue