Where does the bug appear (feature/product)?
Cursor IDE
Describe the Bug
Cursor sends the prompt to the model without waiting for the beforeSubmitPrompt hook to finish. A hook that answers {"continue": false} (or exits with code 2) blocks the prompt only if it answers almost instantly. If the hook takes even 1 second, the block is ignored, user_message is not shown, and the agent replies to the prompt.
This contradicts the hooks documentation (Hooks | Cursor Docs), which says beforeSubmitPrompt “can prevent submission” with continue: false, and which lets each hook set a timeout.
In practice, a hook that does any real work before deciding can no longer block a prompt. That includes scanning the prompt for secrets, or asking the user to confirm. This used to work.
Measured on Cursor 3.24.18, Windows 11, with the test hook below. Each row is a new chat. We logged the hook’s start time, its exact stdout and exit code, and when it answered, so the hook’s output is confirmed for every row:
| Hook answer | Answered after | Result |
|---|---|---|
{"continue": false, ...}, exit 0 |
0 s | Blocked |
{"continue": false, ...}, exit 2 |
0 s | Blocked |
{"continue": false, ...}, exit 0 |
1 s | Not blocked (tried twice) |
{"continue": false, ...}, exit 0 |
2 s | Not blocked |
{"continue": false, ...}, exit 2 |
5 s | Not blocked |
{"continue": false, ...}, exit 2 |
10 s | Not blocked |
The hook’s stderr is also not shown in the Hooks output channel.
Steps to Reproduce
-
Save this as
block_test.py:import json, sys, time event = json.loads(sys.stdin.buffer.read().decode("utf-8-sig")) words = event.get("prompt", "").split() block = {"continue": False, "user_message": "Blocked by the test hook"} if "block-now" in words: # answer at once print(json.dumps(block)); sys.exit(0) if "block-after" in words: # answer after N seconds, e.g. "block-after 2 hello" time.sleep(float(words[words.index("block-after") + 1])) print(json.dumps(block)); sys.exit(0) print(json.dumps({"continue": True})) -
Add it to
~/.cursor/hooks.json:{ "version": 1, "hooks": { "beforeSubmitPrompt": [ { "command": "python /absolute/path/to/block_test.py", "timeout": 60 } ] } } -
Reload the window. In a new chat for each, send:
block-now hello: blocked, as expected.block-after 1 hello: expected blocked; actually the agent replies.block-after 5 hello: expected blocked; actually the agent replies.
Expected Behavior
The prompt is not sent to the model until every beforeSubmitPrompt hook has returned, up to its configured timeout. A hook that returns {"continue": false} within its timeout blocks the prompt and shows user_message, however long it took.
Operating System
Windows 10/11
Version Information
Version: 3.24.18 (user setup)
VS Code Extension API: 1.128.0
Commit: be4c9e5350d77747b42cd467cbd3370a753d4640
Date: 2026-10-13T18:12:58.182Z
Layout: Agent Window
Build Type: Stable
Release Track: Default
Electron: 42.10.0
Chromium: 148.0.7778.280
Node.js: 24.18.1
V8: 14.8.178.38-electron.0
xterm.js: 6.1.0-beta.291
OS: Windows_NT x64 10.0.26200
Additional Information
- Cursor passes the hook’s stdin with a UTF-8 BOM, so
json.loadsneedsutf-8-sig. - Related threads: beforeSubmitPrompt hook block is broken,
Does this stop you from using Cursor
Sometimes - I can sometimes use Cursor