Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
A sessionStart user hook that writes {“additional_context”: “…”} to stdout per the documented schema is loaded and executed by Cursor (verified via the Hooks output channel and via a side-channel debug log written by the hook itself), but the returned additional_context value is never added to the agent’s initial system context.
Reference: Hooks | Cursor Docs — the docs explicitly state that additional_context is “added to the conversation’s initial system context.”
Steps to Reproduce
- Create ~/.cursor/hooks.json with a sessionStart hook whose command echoes a JSON object containing additional_context, e.g.:
{
"version": 1,
"hooks": {
"sessionStart": [
{ "command": "echo '{\"additional_context\":\"CURSOR_HOOK_REPRO_MARKER_8F3A2B1C\"}'" }
]
}
}
- Open the Output panel and select the “Hooks” channel; confirm:
Loaded 1 user hook(s) for steps: sessionStart
- Start a brand new agent session in any workspace.
- Ask the agent: “What is the value of CURSOR_HOOK_REPRO_MARKER_8F3A2B1C in your context?” (or any question that would force it to reveal injected initial context).
The agent has no awareness of the marker string, indicating additional_context was never injected into its initial system context. The hook itself fires (verifiable by adding side-channel logging from the hook command) and produces valid JSON on stdout matching the documented schema.
Expected Behavior
Per the documentation at Hooks | Cursor Docs, the additional_context field returned by a sessionStart hook should be “added to the conversation’s initial system context.”
For the repro hook above, the marker string CURSOR_HOOK_REPRO_MARKER_8F3A2B1C should be present in the agent’s initial system context, so that asking the agent about the marker returns a recognizable value (or the agent reports having seen it in its instructions).
Actual behavior: the agent has no knowledge of the marker. The Hooks output channel confirms the hook is loaded and (with diagnostic logging in the hook) confirms the hook command runs and writes the documented JSON to stdout. Cursor appears to load and execute the hook but never inject its additional_context output into the session.
Operating System
MacOS
Version Information
Version: 3.1.15
VSCode Version: 1.105.1
Commit: 3a67af7b780e0bfc8d32aefa96b8ff1cb8817f80
Date: 2026-04-15T01:46:06.515Z
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
Additional Information
Diagnosis details:
- The hook command is invoked. Verified by writing a side-channel debug log from the hook: each new agent session produces a log line with the correct PID, CURSOR_PROJECT_DIR, and cwd.
- The hook writes valid JSON of the documented shape to stdout. Verified by capturing stdout from the same logging wrapper.
- The Hooks output channel reports
Loaded 1 user hook(s) for steps: sessionStartat startup. No errors are reported about parsing the hook output. - Despite (1)–(3), the marker string never appears in the agent’s initial system context across many fresh sessions.
- Verified the same with the minimal
echorepro hook above (i.e., not specific to a Python script).
Related existing report (different surface, same root cause area: project-wide instructions failing to reach the agent context): AGENTS.md not automatically injected — the documented sessionStart hook would be the natural workaround for that issue, except it does not work either.
Documented contract referenced: Hooks | Cursor Docs
Does this stop you from using Cursor
No - Cursor works, but with this issue