SDK 1.0.37 local agent stream reports Connection stalled after exactly 30s without inbound frames

Where does the bug appear (feature/product)?

Cursor SDK

Describe the Bug

Local @cursor/sdk 1.0.37 agent streams end with Connection stalled / connection_stalled after exactly 30 seconds with no inbound frames. Two runs of the same agent produced a steady thinking stream, then stopped. The gaps from the last thinking event to the error were 30.009s and 30.016s. An earlier 31.8s gap with no public events, before the first thinking token of the second run, did not stall. Client heartbeats every 5 seconds do not reset the SDK 30,000ms inbound-activity watchdog; server heartbeats do. enableAgentRetries is false. No API keys, prompts, or private reasoning are included.

Steps to Reproduce

  1. Node 24.16.0, @cursor/sdk 1.0.37, local runtime, sandbox enabled, enableAgentRetries=false. Agent.resume keeps the original agent and workspace and uses a copied JsonlLocalAgentStore with custom tools only.
  2. Model: Grok 4.7 High, 256k context, fast=false. API host: api2.cursor.sh.
  3. Request abbb805d-32fd-4828-9729-d2d660903ba2, run run-cfb29809-781a-4e18-9abb-500ab4760087: 719 thinking events and 26 tool calls fully returned. Last thinking 2026-10-12T07:30:40.596Z. Error 2026-10-12T07:31:10.605Z.
  4. Request 780006f8-d517-4443-8a28-de52b8129228, run run-04774591-1d75-4a04-b288-ebbd4ae0d7ba: 250 thinking events over about 206 seconds, zero tool calls. Last thinking 2026-10-12T14:20:57.930Z. Error 2026-10-12T14:21:27.946Z.
    Agent ID: agent-5eb7a0e5-1d66-417f-8485-ef41c05e4bb6. The installed SDK already contains the 29-second HTTP/2 idle close and 59-second ping changes from the 1.0.34 notes.

Expected Behavior

A stream that is still receiving server heartbeat frames should continue when public content events pause. The second run already survived a 31.8s public-event gap before the first thinking token. If inbound frames truly stop, the error should say whether the close came from the client 30s watchdog or from a server reset.

Operating System

MacOS

Version Information

macOS, Node 24.16.0, @cursor/sdk 1.0.37, local runtime. API key name on this forum account: Codex Cursor executor.

For AI issues: which model did you use?

grok-4.7, context 256k, reasoning high, fast=false

For AI issues: add Request ID with privacy disabled

abbb805d-32fd-4828-9729-d2d660903ba2
780006f8-d517-4443-8a28-de52b8129228

Additional Information

Please trace both request IDs and answer:

  1. After the last thinking event on each request, did the server keep sending heartbeat frames? When was the last frame sent, and was the close a client watchdog cancel or a server reset?
  2. Was the model upstream still generating, stalled, or already closed at 07:31:10.605Z and 14:21:27.946Z?
  3. Which Http2Config applied: FORCE_BIDI_ENABLED, FORCE_BIDI_DISABLED, or UNSPECIFIED?
  4. Is there a supported fix other than enabling broad agent retries? enableAgentRetries also retries other connection failures, so it is still off.
    The same agent, model, and task are retained. The production run has not been retried.

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Hey @Sijie_Gu, thanks for the report — the request IDs made this easy to trace.

1. Heartbeats / who closed the connection

On both requests, our server kept the run alive and sent heartbeats every 10s, whether or not the model was emitting thinking events. connection_stalled is only raised by the SDK’s own 30s inbound watchdog, so this was a client-side close, not a server reset (a server reset shows up as a different error). For the watchdog to fire, three consecutive heartbeats never reached your process.

  • Request 1: we didn’t see the connection drop until ~17 min later — typical when packets stop flowing on the network path and nothing acknowledges them.
  • Request 2: we saw your close ~13s after your error, so that path recovered on its own after ~45s.

2. Model upstream

Still generating on both. Each run was mid-step, producing a tool call after its last thinking output. That step finished ~5 min later (request 1) and ~10s later (request 2).

3. Http2Config

UNSPECIFIED for your account. On Node that means the default HTTP/2 bidi stream, which matches what we saw.

4. Options besides broad retries

  • Your traffic reaches us from a datacenter IP in Singapore rather than a home or office network, which usually means a VPN or proxy. Try the same task with it off, or via a different exit — that’s the most likely place frames are being dropped.
  • To test whether HTTP/2 over that path is the trigger, call configureCursorSdk({ local: { useHttp1ForAgent: true } }) before creating the agent. This switches the agent stream to HTTP/1.1 with SSE.
  • For a narrow retry: catch the error, confirm the code is connection_stalled (it’s marked retryable), and resume the agent yourself. Other connection failures behave as before.
  • If you re-enable enableAgentRetries, stall retries are capped at ~3 min. Note that a custom tool call in flight when the drop happens can run again with the same toolCallId, so make your custom tools idempotent per toolCallId first.

If it still stalls with the VPN/proxy off, send the new request ID and UTC time and we’ll dig in again.