Skip to content

fix(provider): recycle sidecar after idle/terminal errors#75

Closed
justin-carper wants to merge 1 commit into
mainfrom
fix-cursor-inactivity-err
Closed

fix(provider): recycle sidecar after idle/terminal errors#75
justin-carper wants to merge 1 commit into
mainfrom
fix-cursor-inactivity-err

Conversation

@justin-carper

Copy link
Copy Markdown
Collaborator

Summary

  • After opencode sits idle (15–60min+), every subsequent Cursor turn fails with Cursor run ended with status "error". /new does not help; only restarting opencode does.
  • Root cause: the Node sidecar hosts @cursor/sdk, which memoizes its streaming transport with no reconnect. Cursor's backend drops idle sessions; unary RPCs still succeed (so runs get created), but the dead stream ends every run status:"error". The dead state is process-wide → fails fresh sessions too.
  • Fix: recycle the sidecar child after 10 minutes idle and after any terminal run error. Next request spawns a fresh child (fresh transport). Pooled agents resume from Cursor's checkpoint store — same path as an opencode restart. Complements fix(session): retry resumed turns that fail against an expired Cursor agent #52 (per-agent resume retry), which cannot heal a shared dead transport.

Test plan

  • npm run typecheck
  • npm test (310 tests)
  • npm run build
  • Sidecar unit tests: recycle on status error, recycle on idle TTL, keep child across healthy turns, never recycle while a sibling request is in flight
  • Manual: leave opencode idle 20+ minutes under Bun + Node sidecar; send a message — should succeed (or fail once then succeed on next message before this fix would require a restart)

Cursor's SDK memoizes its streaming transport with no reconnect. After
an idle gap (15-60min+), the backend drops the session and every later
run ends `status:"error"` until the process restarts — /new doesn't help
because the state lives in the long-lived Node sidecar child.

Recycle the child after 10 minutes idle (below the shortest reported
onset) and after any terminal run error. Pooled agents resume from
Cursor's checkpoint store on the next turn, same path as an opencode
restart. Complements #52's per-agent resume retry, which cannot heal a
dead transport shared by every subsequent agent in the same child.
@justin-carper
justin-carper force-pushed the fix-cursor-inactivity-err branch from f034bb3 to 5255909 Compare July 24, 2026 15:45
@justin-carper

Copy link
Copy Markdown
Collaborator Author

Closing as superseded by #76 (v0.5.0 native experience overhaul).

Rationale:

Remaining gaps worth tracking separately (not addressed here):

  1. Fresh-turn (/new) inactivity error is not retried on any transport (Native experience overhaul: reliability, streaming fidelity, transport (v0.5.0-next.0) #76's retry is gated on acquired.resumed).
  2. No confirmation of whether the idle failure reproduces on the http1 in-process default.

If either proves to be a real problem, the right fix is a transport-agnostic reset/retry for fresh turns, not sidecar-child recycling.

@justin-carper
justin-carper deleted the fix-cursor-inactivity-err branch July 24, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant