Skip to content
Source
Sign inSign up
pingdotgg/t3code

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

ClosedATECHPCS(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/12337/headopened View on GitHub

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.
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      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](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. 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 1455cb5c35e50211145073be6ca155d56684f0f4 and e832010f1d34e4eafbb9bb58f2e4f0c7c76aede1.

      📒 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 nameStatusExplanationResolution
      Docstring Coverage⚠️ WarningDocstring 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 nameStatusExplanation
      Title check✅ PassedThe title clearly and concisely describes the primary change: recycling Cursor sessions after transport failures.
      Description check✅ PassedThe 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✅ PassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes check✅ PassedCheck 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.
    4. juliusmarminge added labelsmacroscope-review

    5. 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.

    6. juliusmarminge closed this

Sign in to join this conversation.