Cursor agent -p (print/headless mode) hangs indefinitely and never returns

Where does the bug appear (feature/product)?

Cursor CLI

Describe the Bug

Environment:
• Cursor Version: 2.4.22 (618c607a)
• Cursor Agent Version: 2026.01.28-fd13201
• OS: macOS 26.2 (Build 25C56)
• Architecture: arm64

Steps to Reproduce

The cursor agent command with -p (print/non-interactive) flag hangs indefinitely and never returns a response, making it unusable for scripting.
Steps to Reproduce:

  1. Ensure you’re logged in: cursor agent status (shows authenticated)

  2. Run any prompt in print mode:

    cursor agent -p --output-format text “Say hello”

  3. Command hangs indefinitely (tested for 90+ seconds with no response)

Expected Behavior

Command should return the AI response to stdout and exit.
Command hangs indefinitely with no output. Tested with:
• --model gpt-4o-mini - still hangs
• Simple prompts like “Say hello” - still hangs

Trying to use cursor agent -p for automated commit message generation in a shell script.

Operating System

MacOS

Version Information

• Cursor Version: 2.4.22 (618c607a)
• Cursor Agent Version: 2026.01.28-fd13201
• OS: macOS 26.2 (Build 25C56)
• Architecture: arm64

For AI issues: which model did you use?

The issue shows in all model

Does this stop you from using Cursor

Yes - Cursor is unusable

Hey, thanks for the bug report.

Your command syntax looks correct. A few things that can help with debugging:

  1. Does it work in interactive mode (without -p)? Try:

    agent "Say hello"
    
  2. Try streaming output to see if anything is coming through:

    agent -p --output-format stream-json "Say hello"
    
  3. When it hangs, is it completely silent, or do you get any initial output?

  4. Check cursor agent status. Are your credentials valid?

  5. Try a different model explicitly:

    agent -p --model sonnet-4.5 "Say hello"
    

Let me know what you find.

Here are my findings:

  1. Interactive mode (without -p):
    :white_check_mark: Works fine. cursor agent “Say hello” returns a response as expected.
  2. Streaming output (--output-format stream-json):
    cursor agent -p --output-format stream-json “Say hello”
    :cross_mark: Completely silent. No output after 30+ seconds, had to kill the process.
  3. Behavior when hanging:
    Completely silent - no initial output, no error messages, no partial responses. Zero output to stdout or stderr.
  4. Credentials:
    ✓ Logged in as
  5. Different model (sonnet-4.5):
    cursor agent -p --model sonnet-4.5 “Say hello”
    :cross_mark: Also completely silent. Same hang behavior.
    Summary:
    • Interactive mode: :white_check_mark: Works
    • Print mode (-p): :cross_mark: All variations hang with zero output
    • --output-format text - hangs
    • --output-format stream-json - hangs
    • --model gpt-4o-mini - hangs
    • --model sonnet-4.5 - hangs

The issue appears to be specifically with the -p flag. Something in headless/print mode isn’t initiating the request or is blocking before any output is produced.

Adding more debugging details from our investigation:

Same issue here. Cursor 2.4.21 (arm64 macOS), cursor-agent version 2026.01.28-fd13201.

What we found with lsof/network analysis:

  • cursor agent status shows logged in ✓
  • cursor agent –print hangs with zero output
  • Critically: lsof -p <pid> shows the agent process has NO TCP connections — it’s stuck waiting on internal unix sockets, never making API calls to Cursor servers
  • Worker-server processes (worker-server) also have no network connections
  • Killing worker servers and retrying doesn’t help
  • Network connectivity to api2.cursor.sh is fine (verified with curl -v)
  • Streaming mode (--output-format stream-json) also hangs with no output

Use case: Running cursor agent as a subprocess from a Node.js Slack bot. The 5-minute timeout always hits.

This appears to be an IPC hang between the CLI process and internal worker-server, not an API/auth/network issue. The agent never even attempts to make network requests.