Where does the bug appear (feature/product)?
Cursor CLI
Describe the Bug
Cursor CLI invokes some hooks on macOS, but it does not emit the complete lifecycle that an equivalent Cursor IDE invocation emits.
The CLI successfully invoked session, thought, tool, file-read, and session-end hooks. However, it did not invoke: beforeSubmitPrompt , afterAgentResponse, stop. The equivalent IDE invocation emitted all three events.
This is particularly important for observability integrations. We are building an agent observability tool that reconstructs traces from Cursor hook events. It relies on:
- conversation_id for conversation-level correlation,
- generation_id for model-generation correlation,
- beforeSubmitPrompt for the beginning of a user turn ,
- afterAgentResponse for the authoritative final response,
- stop for final status, loop count, and aggregate token usage.
In CLI mode, the missing afterAgentResponse and stop events mean that the hook stream contains neither the authoritative final assistant response nor any token-usage information.
There is also a separate correlation issue: the CLI uses the conversation_id as the generation_id for session and tool events, while afterAgentThought events use a different family of suffixed generation IDs. This makes it unclear how tool events should be associated with the actual model generation.
Steps to Reproduce
-
Create a non-blocking hook handler that reads the JSON payload from standard input and appends it to a log file.
-
Register the handler against all available Cursor hooks in hooks.json, including at least:
sessionStart
beforeSubmitPrompt
afterAgentThought
preToolUse
postToolUse
beforeReadFile
afterAgentResponse
stop
sessionEnd -
From a repository, invoke Cursor CLI using model composer-2.5.
-
Give the agent a small task. Let the run complete normally.
-
Review the recorded hook sequence.
-
Run an equivalent prompt from Cursor IDE against the same repository and model.
-
Compare the hook sequences and payload fields.
Expected Behavior
-
Cursor CLI should provide enough hook information to reconstruct the same logical agent turn as Cursor IDE. Ideally, the CLI should emit:
sessionStart
beforeSubmitPrompt
afterAgentThought
preToolUse
postToolUse
afterAgentResponse
stop
sessionEnd -
At minimum, one terminal CLI hook should provide:
conversation_id
generation_id
model
model_id
final response text
status
loop_count
input_tokens
output_tokens
cache_read_tokens
cache_write_tokens -
All thought, tool, response, and terminal events belonging to one model generation should expose either:
The same stable base generation_id, or
An explicitly documented parent-generation field that permits deterministic correlation.
Clarity on the behaviour of hooks in cli mode will be much helpful:
-
Is the absence of beforeSubmitPrompt, afterAgentResponse, and stop in Cursor CLI 2026.08.11-e8db854 expected?
-
Is this a known regression or an intentionally unsupported part of CLI hook behavior?
-
Is sessionEnd intended to replace stop in CLI mode?
-
If sessionEnd replaces stop, can it expose token usage, loop count, final response text, and the actual model-generation ID?
-
Why do CLI afterAgentThought hooks use a separate suffixed generation-ID family which is different from the base generation id with which the current generation starts ?
-
Is full lifecycle and payload parity between Cursor IDE and Cursor CLI planned?
Operating System
MacOS
Version Information
Cursor CLI version: 2026.08.11-e8db85
Does this stop you from using Cursor
No - Cursor works, but with this issue. Although, this is a blocker for us to build our internal observability tool.
sample-output-ide-run.json.txt (12.5 KB)
sample-output-cli-run.json.txt (8.0 KB)