fix(cursor): resume moved threads from their original session store #34794
main fromrefs/pull/34794/head·merged by Yash-Singh1(GitHub profile, opens in a new tab) View on GitHubProblem#
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/mainwith the ort strategy,vp run check:changedpassed 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
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
a6db833Macroscope'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).Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅ Codex Live turn messages 1 1 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅ Claude Live turn messages 1 1 0 (0.0%) 8 ✅ Baseline:
4bf5d53· PR result:a6db833· Source CI: successScenario 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.
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.tsThread 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.tsThe 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 cursorStoreCwdPossibly 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 toa6db8-
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:
4-
Check name Status Explanation Title check 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 … Description check 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 se… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check 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-
- Source mode: Auto
- Repository: pingdotgg/t3code
- Branch: t3/explain-context-handoff
- File: .coderabbit.config.ts
- Commit: a6db833
- Layers: Repository TS config
- Review profile: CHILL
- Plan: Team
- Run ID:
ca09cad5-8cc2-46aa-ae09-0867e8ee8e8f
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.tspackages/provider-cursor/src/server/CursorAgentSdk.test.tspackages/provider-cursor/src/server/CursorAgentSdk.tspackages/provider-cursor/src/server/adapter.test.tspackages/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.
-
-
Yash-Singh1(GitHub profile, opens in a new tab) closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes