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:
Ensure you’re logged in: cursor agent status (shows authenticated)
Run any prompt in print mode:
cursor agent -p --output-format text “Say hello”
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.
Interactive mode (without -p): Works fine. cursor agent “Say hello” returns a response as expected.
Streaming output (--output-format stream-json):
cursor agent -p --output-format stream-json “Say hello” Completely silent. No output after 30+ seconds, had to kill the process.
Behavior when hanging:
Completely silent - no initial output, no error messages, no partial responses. Zero output to stdout or stderr.
Credentials:
✓ Logged in as
Different model (sonnet-4.5):
cursor agent -p --model sonnet-4.5 “Say hello” Also completely silent. Same hang behavior.
Summary:
• Interactive mode: Works
• Print mode (-p): 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.