preToolUse hides user_message and ignores agent_message — Cursor 3.23.23

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

TLDR

Cursor blocks the shell command as expected.

However, the tool display shows “Skipped” without the hook message. The shell result formatter uses user_message for model text. The same deny path does not use agent_message.

We found these results in saved session data and separate tests of functions from Cursor 3.23.23.

Actual results

The hook returns valid JSON with permission: "deny" and user_message: "Tool was blocked". The hook finishes with exit code 0.

The screenshot shows “Skipped echo”. The tool row does not show “Tool was blocked”. The agent then explains the block in its own response.

The saved tool result for echo "hi" contains:

{
  "output": "Rejected: Tool was blocked\n\nAgent note: Do not suggest workarounds to the blocked tool.",
  "exitCode": 1,
  "rejected": true
}

The saved display status is rejected. Thus, Cursor receives and stores the message. The fault is not a missing hook response.

Separate function tests

These tests used functions from the installed application with inert dependencies. They did not start new agent sessions. Each response contained permission: "deny".

Message fields in the response Text selected for the model
user_message: "Tool was blocked" Tool was blocked
user_message: "USER_MARKER" and agent_message: "AGENT_MARKER" USER_MARKER; no AGENT_MARKER
agent_message: "AGENT_MARKER" only Default rejection text; no AGENT_MARKER

A separate merge test kept both fields. The fault occurs after the merge.

The display component test returned an ActionLine with action: "Skipped" and details: "echo hi". It did not contain the hook message.

Steps to Reproduce

Use a separate test project.

  1. Configure a preToolUse hook with the matcher Shell.
  2. Make the hook return this JSON for an echo command:
{
  "permission": "deny",
  "user_message": "Tool was blocked"
}
  1. Make the hook finish with exit code 0.
  2. Ask the agent to run echo "hi".
  3. Examine the tool display and the agent response.

Example project configuration in .cursor/hooks.json:

{
  "version": 1,
  "hooks": {
    "preToolUse": [
      {
        "command": ".cursor/hooks/block-echo.sh",
        "matcher": "Shell"
      }
    ]
  }
}

Expected Behavior

The Cursor preToolUse documentation gives different functions to the two message fields.

When a hook returns permission: "deny":

  1. Cursor must block the tool call.
  2. Cursor must show user_message to the user.
  3. Cursor must send agent_message to the agent, if the field is present.

The documentation does not require a specific display type. A dialog is not necessary.

The documentation also does not state that user_message must remain hidden from the model. This report concerns the missing user display and the unused agent_message.

Screenshots / Screen Recordings

Operating System

MacOS

Version Information

Product: Cursor IDE
Version: 3.23.23
Commit: 2dac2428994fe34f12658d9ecad1541b98db2c00
Build date: 2026-10-05T01:43:43.807Z
Operating system: macOS 26.6.2 arm64
Hook event: preToolUse
Tool matcher: Shell

Additional Information

Source evidence for this build

The inspected files belong to the installed Cursor application. We did not change them.

Tool code

File: /Applications/Cursor.app/Contents/Resources/app/extensions/cursor-agent-exec/dist/main.js

The async function N deny branch selects a.user_message. It does not read a.agent_message:

const r = a.user_message || `${o.toolName} blocked by preToolUse hook`

The branch starts at zero-based UTF-16 offset 2456350. The shell result formatter, function qz, starts at offset 5869445. It formats a rejected result as:

case "rejected":
  return `Rejected: ${r.value.reason}`;

SHA-256:

3affaeaee235d9f940ac575b1dc77aff188a85192d0db7d738431599e45d6175

Display code

File: /Applications/Cursor.app/Contents/Resources/app/out/vs/workbench/workbench.desktop.main.js

The rejected-result handler stores the message and sets the display status to rejected at offset 18234453.

The status check at offset 11082296 treats rejected as a dismissed tool call.

The root component, function _Yg, starts at offset 11105437. For a dismissed tool call, it returns “Skipped” before it creates the output display.

SHA-256:

444498c2672d6172416654b60d267bff8457277441de0049b7a2147468528ad8

Scope

The evidence applies to the local shell path in Cursor 3.23.23. We did not verify all tools, cloud agents, or other versions.

The tool block works. This report concerns message selection and message display.

Please preserve the block, show user_message, and send agent_message to the agent.

Does this stop you from using Cursor

No - Cursor works, but with this issue

I can’t confirm the root cause, but one thing may be worth a quick try while this is open. The hooks docs list the same two fields on the dedicated beforeShellExecution hook output (permission, user_message, agent_message), and their example denies a git command with both set. Your trace is on the generic preToolUse deny branch, so the shell-specific hook may go through a different path.

This is untested on 3.23.23, so treat it as a guess. If it behaves the same way there, that would also be useful for the Cursor team to know.

Hey @tnivtego, you’re right on both points: a preToolUse deny currently shows only Skipped without your user_message, and agent_message isn’t passed to the agent. We’ve let the team know, and this is an issue we’re tracking.

For now, put anything the agent needs in user_message, since that’s the text it receives on a deny. (@sattyamjjain, beforeShellExecution behaves the same way today, so switching hooks won’t help.)

I’ll post here when there’s an update.