Skip to content

fix(cursor): pin session id and continue external tool results as userMessageAction - #1990

Merged
lidge-jun merged 3 commits into
lidge-jun:devfrom
laerad777:fix/cursor-session-id-thread-reuse
Aug 18, 2026
Merged

fix(cursor): pin session id and continue external tool results as userMessageAction#1990
lidge-jun merged 3 commits into
lidge-jun:devfrom
laerad777:fix/cursor-session-id-thread-reuse

Conversation

@laerad777

Copy link
Copy Markdown
Contributor

Summary

  • External Cursor wire models now send tool-result continuations as userMessageAction (results stay in history blobs). Native models keep resumeAction.
  • Connect x-session-id is pinned to the resolved conversation id so transport rebuilds for the same client thread keep one session identity. Native-exec / background shells use a separate per-transport owner.
  • Isolated helper / compaction turns still mint a fresh conversation id, so they do not inherit the parent Connect session.

Rebase source commits: 0046816b3, 4d5850e4d, e3c996586 on current dev (1645bb924).

Verification

  • bun run typecheck — clean
  • bun run privacy:scan — Privacy scan passed
  • bun run test — 12812 pass, 10 skip, 0 fail (826 files)
  • Focused: bun test tests/cursor-live-transport.test.ts tests/cursor-adapter.test.ts tests/cursor-blob.test.ts tests/cursor-hardening.test.ts tests/cursor-transport-retry.test.ts — 147 pass

Live Connect probes informed the encoding choice; the unit tests only lock the action case, session-id forwarding, helper isolation, and shell-owner split. They do not claim to reproduce a 45k-token Connect reject.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed. (no public API / GUI / docs change)
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults. (no auth, credentials, workflows, or install-path changes)

Review readiness checklist

  • All CI tests are green on my local testing.

  • I pushed my PR to the latest dev commit.

  • I resolved all correct Codex and CodeRabbit findings.

  • My PR is ready for review.

mose added 3 commits August 18, 2026 12:59
Reuse the resolved conversationId as Connect x-session-id so
transport rebuilds for the same client thread keep one session
identity. Fall back to a random UUID only when no session identity
exists. Native-exec/background shells use a separate per-transport
owner (see follow-up commit).
…ction

Drive external-model tool-result hops as userMessageAction so
history-blob tool results stay visible without ResumeAction. Native
models keep resumeAction. Live Connect probes informed this encoding
choice; unit tests only lock the action case.
Independent review: do not claim the 429 diagnosis from unit tests, keep
native-exec/background shells on a per-transport owner so overlapping
turns cannot reap each other, and lock sessionId forwarding in adapter
plus Connect header tests.
@github-actions

Copy link
Copy Markdown
Contributor

Deterministic PR hygiene checks passed.

@github-actions github-actions Bot added the bug Something isn't working label Aug 18, 2026
@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 877e2500-b66a-45d6-b62a-7fb38d8aa287

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions

Copy link
Copy Markdown
Contributor

⏳ DRAFT

  • review readiness checklist open (0/4 boxes ticked).

What to do

  • Tick all four boxes in the PR description once you're done (currently 0/4).

Review readiness checklist

  • ⬜ All CI tests are green on my local testing.
  • ⬜ I pushed my PR to the latest dev commit.
  • ⬜ I resolved all correct Codex and CodeRabbit findings.
  • ⬜ My PR is ready for review.

0/4 boxes ticked.

This PR stays in draft until every box above is ticked.

@lidge-jun

Copy link
Copy Markdown
Owner

Keeping this draft open — direction for whoever picks it up (maintainer decision):

What is already on dev (do not re-implement): external tool results continuing as userMessageAction landed with the cursor-call campaign. Rebase first; the half of this diff that duplicates it should disappear in the rebase.

What this PR is still uniquely for: session-id pinning. The adapter still generates a fresh randomUUID() per request, so Cursor sees every turn as a new thread and server-side thread reuse/caching never engages. The remaining work is to pin one stable session id per logical conversation and reuse it across continuations.

Constraints for the implementation:

After rebase, re-scope the PR description to session pinning only, then it can leave draft.

lidge-jun added a commit that referenced this pull request Aug 18, 2026
fix(cursor): pin session id and continue external tool results as userMessageAction (lands #1990)
@lidge-jun
lidge-jun merged commit c6b8d7e into lidge-jun:dev Aug 18, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants