Skip to content

fix(cursor): recover from cursor agent http/2 transport drops - #565

Merged
astyfx merged 2 commits into
mainfrom
fix/cursor-bugs
Sep 21, 2026
Merged

astyfx merged 2 commits into
mainfrom
fix/cursor-bugs

Conversation

@astyfx

@astyfx astyfx commented Sep 21, 2026

Copy link
Copy Markdown
Member

Summary

Recover from Cursor Agent HTTP/2 transport drops that the CLI reports as RetriableError envelopes, so a dropped stream ends as a real failure with a Resume path instead of being recorded as a finished answer.

Changes

Fixes

  • cursor: classify Cursor Agent RetriableError envelopes (PING timed out, NGHTTP2_INTERNAL_ERROR, generic [unavailable]/[internal], [resource_exhausted]) from both stderr and the last line of an ACP assistant text chunk that still answers session/prompt with end_turn.
  • cursor: end a classified drop as runtime_failure and strip the raw RetriableError line from the transcript instead of keeping it as assistant text.
  • cursor: stop appending agent login help to transport/capacity failures; a last-line stream_drop gets one same-session continuation, while capacity does not auto-retry.
  • session: surface a transport recovery notice (data-provider-error="transport") so a terminal drop offers Resume.

Test Evidence

  • bun run typecheck: clean (tsc --noEmit).
  • bun test tests/cursor-agent-transport.test.ts tests/cursor-acp-runtime.test.ts tests/provider-error-recovery.test.ts: 37 pass / 0 fail (113 assertions), covering stderr and assistant-text PING/NGHTTP2 classification, same-session continuation, capacity no-retry, prose-mention false-positive guard, envelope stripping, and recovery eligibility.

Notes

  • Stave cannot keep the Agent↔Cursor backend HTTP/2 socket alive — that socket is owned by the agent acp process, not ACP. This PR is recovery (classify + continue/Resume), not prevention.
  • No dependency or package.json changes; the license gate is not applicable to this diff.

Cursor Agent writes RetriableError envelopes (PING timed out, NGHTTP2_INTERNAL_ERROR, generic [unavailable]/[internal], resource_exhausted) either on stderr or as the last line of an ACP assistant text chunk that still answers session/prompt with end_turn, so drops were recorded as finished answers.

Classify the envelope from both stderr and last-line assistant text, strip the raw envelope from the transcript, end the turn as runtime_failure, and stop appending agent login help to transport/capacity failures. A last-line stream_drop gets one same-session continuation; capacity does not auto-retry. Surface a transport recovery notice so a terminal drop offers Resume.
@astyfx
astyfx requested a review from a team as a code owner September 21, 2026 08:30
@astyfx
astyfx requested review from JongSikLim and schang124 and removed request for a team September 21, 2026 08:30
@upwind-code-us

upwind-code-us Bot commented Sep 21, 2026

Copy link
Copy Markdown

Upwind Upwind Code Scan - ✅ Passed

0 newly introduced vulnerabilities · 7 resolved · 57 total in this PR vs main

Total breakdown: 🔶 6 High | 🟡 48 Medium | 🟢 3 Low


Resolved · 7 findings
CVE Package Version
CVE-2026-76172 fast-uri 3.1.0
CVE-2026-13676 fast-uri 3.1.0
CVE-2026-16221 fast-uri 3.1.0
CVE-2026-75975 fast-uri 3.1.0
CVE-2026-6321 fast-uri 3.1.0
CVE-2026-18446 fast-uri 3.1.0
CVE-2026-6322 fast-uri 3.1.0

View full analysis in Upwind Console

Scan completed in 17s

Scan history (2 scans)
Commit Scanned at New Resolved Net
cb8ff43 2026-09-21 08:30 UTC 0 -7 -7
1181170 < 2026-09-21 08:43 UTC 0 -7 -7

Last scanned: 1181170 · 2026-09-21 08:43 UTC

@upwind-code-us

upwind-code-us Bot commented Sep 21, 2026

Copy link
Copy Markdown

Upwind Upwind IaC Scan - ✅ Passed

0 newly introduced misconfigurations · 0 resolved · 0 total in this PR vs main

View full analysis in Upwind Console →

Scan completed in 5s

Scan history (2 scans)
Commit Scanned at New Resolved Net
cb8ff43 2026-09-21 08:30 UTC 0 0 0
1181170 < 2026-09-21 08:44 UTC 0 0 0

Last scanned: 1181170 · 2026-09-21 08:44 UTC

@astyfx
astyfx enabled auto-merge (squash) September 21, 2026 08:30
…accessor

The main-process typecheck (typecheck:lens-main) narrowed agentTextTransportFailure to null at its read sites because it is only assigned inside the onNotification closure, which control-flow analysis does not treat as reachable, producing TS2339 on .retryable. Read the state through a typed accessor so access sites use the declared type.

@heath-s heath-s left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved

@astyfx
astyfx merged commit 9d40fb9 into main Sep 21, 2026
6 checks passed
@astyfx
astyfx deleted the fix/cursor-bugs branch September 21, 2026 08:52
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.

2 participants