Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(cursor): resume moved threads from their original session store #34794

MergedYash-Singh1(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/34794/headmerged by Yash-Singh1(GitHub profile, opens in a new tab) View on GitHub

Problem

A Cursor thread created in the main checkout can lose its native conversation after its T3 workspace changes to a worktree and the server restarts. Cursor scopes its saved agents by working directory, so T3 looks in the worktree's store, gets AgentNotFoundError, and replaces the intact conversation with a context handoff.

Change

Persist the original Cursor store directory in the provider thread's native metadata. When the execution directory differs, resume through a Cursor SDK platform bound to that original store while passing the current working directory as the execution option. Snapshots and abandoned-run recovery use the same platform. Older threads use their saved provider session directory until the metadata is populated.

Scope and approval

Focused fix for an observed session lookup bug. It preserves the existing conversation instead of reconstructing it after a workspace change. The optional contract field carries the store location across server restarts; there are no client controls or defaults to change.

Verification

  • Added a regression using the real Cursor SDK with isolated storage. Before the fix, resuming the saved agent from another working directory fails with AgentNotFoundError; with the fix, the same native agent resumes and its messages can be read.
  • Repeated the check against isolated SQLite snapshots of the affected session on macOS with SDK 1.2.0. The old lookup failed; the fixed runner resumed the original native agent and loaded its four saved conversation messages. No paid turn was started, and the live databases were opened read-only for copying.
  • After merging origin/main with the ort strategy, vp run check:changed passed formatting, lint, both knip checks, typechecks for 37 affected packages, and 42 tests across four files.

Runtime transcript:

Before: resume from worktree scope failed with AgentNotFoundError.
After: original native agent resumed successfully.
Saved conversation messages recovered: 4

This verifies session recovery and history reads. A model turn from the new execution directory and Windows/Linux runtime behavior were not exercised.

Model: GPT 6.1 Sol. Harness: Codex through T3 Code.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. Approvability

      Verdict: Approved at a6db833

      Macroscope's review found this PR approvable — Moved Cursor threads retain their original session-store location while using the current execution directory and runtime policy. The change is narrowly scoped and introduces no apparent material operational or product-policy risk.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded21.5 KiB21.5 KiB0 B (0.0%)24.4 KiB✅
      CodexLive turn messages110 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.9 KiB21.9 KiB0 B (0.0%)24.4 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Baseline: 4bf5d53 · PR result: a6db833 · Source CI: success

      Scenario and decoded snapshot size

      10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

      • Codex decoded thread snapshot: 108.5 KiB
      • Claude decoded thread snapshot: 108.8 KiB

      Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

    4. Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      Cursor provider threads now retain the working directory associated with the Cursor agent’s store. Resume and snapshot operations pass that directory to the SDK, which can use a store-specific platform to access the agent.

      Changes: Cursor store working-directory resume

      Layer / File(s)Summary
      Store-aware SDK resume
      packages/contracts/src/orchestrationV2.ts, packages/provider-cursor/src/server/CursorAgentSdk.ts, packages/provider-cursor/src/server/CursorAgentSdk.test.ts
      Thread metadata and SDK input include the optional store working directory. When it differs from the configured local working directory, resume and related run and message operations use a platform created with the store directory and optional local store. The test covers resuming from a different working directory using the original store.
      Provider thread directory persistence
      packages/provider-cursor/src/server/adapter.ts, packages/provider-cursor/src/server/adapter.test.ts
      The adapter selects and retains the agent’s working directory, stores it in thread metadata, and passes it to agent resume and snapshot operations. The lifecycle test checks the stored directory.

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

      Change: Bug fix

      Sequence Diagram(s)

      sequenceDiagram
        participant ProviderThread
        participant CursorAdapter
        participant CursorAgentSdkRunner
        participant AgentPlatform
        CursorAdapter->>ProviderThread: Read cursorStoreCwd
        CursorAdapter->>CursorAgentSdkRunner: Open agent with storeCwd
        CursorAgentSdkRunner->>AgentPlatform: Create platform with storeCwd and local store
        CursorAgentSdkRunner->>AgentPlatform: Resume agent and access stored state
        CursorAdapter->>ProviderThread: Update cursorStoreCwd

      Possibly related PRs

      • pingdotgg/t3code#28718: Changes the Cursor SDK service loading and exports used by this PR’s store-specific platform path.

      Suggested reviewers: juliusmarminge, jaiminp007, macroscopeapp

      Merge Risk: Minimal · up to a6db8

      This change lets Cursor threads moved to a worktree resume from their original session store. No concrete merge-blocking issue was identified. The author reports regression testing against the real SDK. A model turn from the new execution directory and Windows/Linux behavior were not exercised.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title names the primary change: Cursor threads now resume from the session store they were originally created in, after a workspace move. It follows the conventional commit format and matches the …
      Description checkPassedThe description follows the template sections (Problem, Change, Scope and approval, Verification) and fills each one with specific content. The Problem section gives the failure mode and the Change se…
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      Full details: Title check

      Explanation

      The title names the primary change: Cursor threads now resume from the session store they were originally created in, after a workspace move. It follows the conventional commit format and matches the raw summary and PR objectives, which describe persisting cursorStoreCwd and resuming through a platform bound to the original store.

      Full details: Description check

      Explanation

      The description follows the template sections (Problem, Change, Scope and approval, Verification) and fills each one with specific content. The Problem section gives the failure mode and the Change section explains the fix. Verification lists a regression test, a macOS SQLite check, and repo checks, and it states what was not exercised. The Scope section cites a focused bug fix but links no triaged issue or maintainer approval comment, and the template asks for that for non-trivial fixes. The model/harness attribution is also present. The gap in approval evidence is the main item to address.

      Resolution

      Consider linking the triaged bug issue or the maintainer approval discussion in the Scope and approval section. The template asks for that link, or for an explanation of why this small, focused fix qualifies without one.

      Finishing Touches

      Generate unit tests (beta)

      • Commit to this branch
      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 4bf5d53d93eedc45ca67d4042a33ca974a8ef567 and a6db833b07514e63ae9205a3ee6c68f4734a3e31.

      Files selected for processing: 5

      • packages/contracts/src/orchestrationV2.ts
      • packages/provider-cursor/src/server/CursorAgentSdk.test.ts
      • packages/provider-cursor/src/server/CursorAgentSdk.ts
      • packages/provider-cursor/src/server/adapter.test.ts
      • packages/provider-cursor/src/server/adapter.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

Sign in to join this conversation.