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.

confirmed for my end to it’s completely messes up my automations, any ETA on that?

Hey Dean,
I took your debugging advice, here are my debugging results:

Environment: Linux Ubuntu, Agent CLI 2026.02.13-41ac335 (latest), team plan user, network egress via Singapore (Zenlayer/CorpLink corporate VPN).

Test results

Test Result
agent “Say hello” (interactive, no -p) Appeared to hang — no output for 20s
agent -p --output-format stream-json “Say hello” Same — completely silent for 20s
agent -p --model sonnet-4.5 “Say hello” Same — silent hang
agent --list-models Works fine (3.4s)
agent login Works fine

Root cause found via strace + ss monitoring:

The agent IS working, but TCP connections to some API backend IPs get stuck in SYN-SENT state (no SYN-ACK from server). The agent silently retries across different IPs until it finds a responsive one. This takes 10-15 seconds on my network, during which there is zero output (no loading indicator, no stderr, nothing).

With timeout 60:

  • agent -p --trust “Say hello” → Succeeded in 13s — replied in Chinese

  • agent -p --trust “What is 2+2?” → Succeeded in 11s — correct answer

TCP state timeline (monitored every 2s during a run):

2s: SYN-SENT → 107.21.32.129:443 (stuck, no SYN-ACK)

4s: (disconnected, retrying)

6s: ESTAB → 3.223.207.45:443 (connected! 1606B sent)

8s: SYN-SENT → 54.160.14.42:443 (2nd connection attempt stuck)

10s: ESTAB → 54.173.34.77:443 (connected to different IP)

Some AWS us-east-1 IPs respond fine from my network; others time out at the TCP level. All IPs are reachable via curl (HTTP 200 in ~0.8s), so it may be an intermittent issue or a protocol-level difference (HTTP/2 long-lived streams vs short requests).

Two issues I’d flag:

  1. UX: Agent CLI produces zero output during connection retries — no spinner, no “Connecting…”, no stderr. Users see a completely frozen terminal.

  2. Network: The retry/failover across API backend IPs adds 10-15s latency from Asia-Pacific networks. A shorter connect timeout per IP or regional endpoint selection could help.

@TerryZ great work with strace and tracking TCP states. This is really useful debugging.

Both issues you called out are on the team’s radar:

  1. UX: Having no output at all (spinner, “Connecting…”, stderr) during TCP retries is genuinely bad UX, especially for headless use and automation.

  2. Network failover: Long connect timeouts to some AWS backend IPs, adding a 10 to 15s delay.

I’ve shared your analysis with the team. There’s no timeline yet, but detailed reports like this help with prioritization.

@dhrubesh @SilasReinagel @Matan_Lasry as a workaround for now, based on TerryZ’s findings, commands in -p mode do finish, but the first connection can take 10 to 15+ seconds.

Let me know if -p mode never returns a result even with a long timeout. That would be a different issue.

Hi all!

This should be fixed in the latest versions of the CLI. Please raise a new thread if you’re still hitting the same issue.