Skip to content

fix(server): recycle Cursor sessions after transport failures - #12337

Closed
ATECHPCS wants to merge 1 commit into
pingdotgg:mainfrom
ATECHPCS:fix/cursor-recycle-transport-failure
Closed

ATECHPCS wants to merge 1 commit into
pingdotgg:mainfrom
ATECHPCS:fix/cursor-recycle-transport-failure

Conversation

@ATECHPCS

@ATECHPCS ATECHPCS commented Sep 18, 2026 •

Copy link
Copy Markdown

Cursor can return a standalone transport diagnostic such as RetriableError: [canceled] http/2 stream closed with error code CANCEL (0x8) after ACP reports a nominally successful prompt. T3 already surfaces that turn as failed, but it kept the compromised ACP child and session registered, so later turns could reuse the broken transport.

This change retires that Cursor session through the existing per-thread lifecycle lock before returning the transport error. It deliberately does not replay the prompt because tools may already have run; the saved resume cursor remains available so the next session can reconnect with session/load without losing conversation context.

The regression test verifies the typed failure, child-process termination, session removal, a single prompt dispatch, and successful resume through a fresh ACP process.

Verification:

  • vp test run apps/server/src/provider/acp/CursorTransportFailure.test.ts apps/server/src/provider/Layers/CursorAdapter.test.ts (43 passed)
  • vp run --filter t3 typecheck
  • targeted vp fmt --check and vp lint

Built with GPT-5 using the Codex harness.

Summary by CodeRabbit

  • Bug Fixes
    • Cursor sessions are now automatically terminated after transport failures.
    • Subsequent requests can start a fresh session while preserving the existing resume context.
    • Improved handling prevents failed sessions from affecting later prompts.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Sep 18, 2026
@macroscopeapp

macroscopeapp Bot commented Sep 18, 2026 •

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at e832010

Macroscope's review found this PR approvable — This targeted fix recycles only Cursor sessions that report a transport failure, terminating the compromised ACP process while preserving the resume context for the next session. The accompanying test verifies cleanup and successful resumption, with no changes to defaults, schemas, deployment, or static-analysis configuration.

Notes:

  • Diff unchanged. Approvability was decided on eligibility alone.

You can add or adjust custom eligibility rules. Learn more.

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Sep 18, 2026
@coderabbitai

coderabbitai Bot commented Sep 18, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Advanced

Run ID: 766e749d-6b8f-4ee0-ad14-5a6c1ca59c7c

📥 Commits

Reviewing files that changed from the base of the PR and between 1455cb5 and e832010.

📒 Files selected for processing (2)
  • apps/server/src/provider/Layers/CursorAdapter.test.ts
  • apps/server/src/provider/Layers/CursorAdapter.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The Cursor adapter now stops a session after a transport failure. The test verifies session removal, process termination, request counts, and resumption with the original cursor.

Changes

Cursor session recycling

Layer / File(s) Summary
Transport failure teardown
apps/server/src/provider/Layers/CursorAdapter.ts
sendTurn stops the active session under the thread lock before returning the transport error.
Session recycling validation
apps/server/src/provider/Layers/CursorAdapter.test.ts
The test verifies session destruction, one termination signal, request counts, and resumed-session loading with the original resumeCursor.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: maria-rcks

Merge Risk: ⚪ Minimal · up to e8320

The session-recycling change has no remaining concrete merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: recycling Cursor sessions after transport failures.
Description check ✅ Passed The description explains what changed, why the change is needed, the implementation approach, regression coverage, and verification results. It does not include the template checklist, but the require…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

Comment @coderabbitai help to get the list of available commands.

@juliusmarminge

Copy link
Copy Markdown
Member

Thanks for working on this. We merged the orchestrator V2 rewrite in #2829, and we are closing this PR as part of that transition.

This change touches CursorAdapter.ts, which the V2 merge removed. Cursor now runs through the SDK-based CursorAdapterV2 instead of the V1 ACP adapter.

Sorry for the extra work this creates. If the change is still needed on V2, please rebuild it on current main, verify it there, and open a new PR linking back here. We're closing the current implementation without assuming the underlying request is resolved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

macroscope-review Opt PRs made by unvouched contributors in for Macroscope review. Vouched contributors auto-reviews size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants