Skip to content

fix: recognize Cursor session-not-found error format#162

Closed
log-li wants to merge 3 commits intoopenclaw:mainfrom
log-li:fix/cursor-session-not-found
Closed

fix: recognize Cursor session-not-found error format#162
log-li wants to merge 3 commits intoopenclaw:mainfrom
log-li:fix/cursor-session-not-found

Conversation

@log-li
Copy link
Copy Markdown

@log-li log-li commented Mar 18, 2026

Summary

Cursor CLI returns error code -32602 with message Session "xxx" not found when session/load fails. This format was not recognized by isSessionNotFoundText(), preventing fallback to session/new.

Problem

When OpenClaw tries to spawn a Cursor ACP session using sessions_spawn(runtime="acp", agentId="cursor"), the following error occurs:

Invalid params - Session "xxx" not found

The root cause is that Cursor's error message format Session "xxx" not found contains the session ID in the middle, so "session not found" is not a substring.

Solution

Added regex pattern to match Session "xxx" not found format:

const SESSION_NOT_FOUND_PATTERN = /session\s+["'\w\-]+\s+not found/i;

Testing

  • ✅ Unit tests pass (254 tests, 0 failures)
  • ✅ Verified with real Cursor CLI error format
  • ✅ End-to-end test with OpenClaw sessions_spawn successful

Fixes #161

@dutifulbob
Copy link
Copy Markdown
Collaborator

Triage result

  • Human attention: ⚠️ Required
  • Recommendation: 🏁 escalate to a human
  • Human decision needed: ready for human landing decision

Quick read

This PR is now in a clean state. It fixes the shared missing-session detection so Cursor's -32602 / Session "..." not found load error goes through the existing session/new fallback path instead of surfacing as a runtime failure. Targeted validation reproduced the regression and proved the fix, final conflict checks are clean, and CI is green on the updated PR head.

Intent

Make acpx recognize Cursor's Session "..." not found ACP load error so a failed session/load is treated as a missing-session case and falls back to creating a fresh session.

Why

  • The underlying bug was real: missing-session detection was too narrow and missed Cursor's error shape.
  • The implementation fixes the shared detector in src/acp-error-shapes.ts instead of special-casing Cursor in the load path.
  • The targeted regression was validated directly: it passed on the PR head, failed after local ablation of the non-test code change, and passed again after restoring the branch state.
  • Initial and final conflict checks against origin/main were both clean.

Codex review

  • No GitHub Codex review findings were present for the current head.
  • The stored local Codex review found no blocking correctness issues in the matcher or its regression coverage.
  • No refactor was needed.

CI/CD

  • The fork PR workflow was approval-blocked; approval was applied.
  • CI then exposed one related failure in Lint: oxlint rejected the escaped - in the new regex character class.
  • That lint issue was fixed on the PR branch, local pnpm run lint was rerun, the targeted regression was rerun (pnpm run build:test and node --test --test-name-pattern='Cursor session-not-found format' dist-test/test/error-normalization.test.js), the branch was pushed, the fresh workflow run for the new head was approved, and the rerun completed green.
  • Current result: all reported CI jobs passed and there are no remaining related failures.

Recommendation

Ready for human landing decision. The bug is reproduced and fixed, the change is localized to the correct shared matcher, CI is green on the updated head, and there are no merge conflicts.

@osolmaz osolmaz self-assigned this Mar 29, 2026
osolmaz added a commit to log-li/acpx that referenced this pull request Mar 29, 2026
@osolmaz osolmaz force-pushed the fix/cursor-session-not-found branch from e8fb493 to 401a944 Compare March 29, 2026 09:32
osolmaz added a commit to log-li/acpx that referenced this pull request Mar 29, 2026
log-li and others added 3 commits March 29, 2026 11:33
Cursor CLI returns error code -32602 with message 'Session "xxx" not found'
when session/load fails. This format was not recognized by isSessionNotFoundText(),
preventing fallback to session/new.

Added regex pattern to match 'Session "xxx" not found' format:
- /session\s+["'\w\-]+\s+not found/i

Fixes openclaw#161
@osolmaz osolmaz force-pushed the fix/cursor-session-not-found branch from 401a944 to 99eef0d Compare March 29, 2026 09:33
@osolmaz osolmaz closed this in #195 Mar 29, 2026
osolmaz added a commit that referenced this pull request Mar 29, 2026
* fix: recognize Cursor session-not-found error format

Cursor CLI returns error code -32602 with message 'Session "xxx" not found'
when session/load fails. This format was not recognized by isSessionNotFoundText(),
preventing fallback to session/new.

Added regex pattern to match 'Session "xxx" not found' format:
- /session\s+["'\w\-]+\s+not found/i

Fixes #161

* fix: satisfy lint for session matcher

* docs(changelog): note Cursor session-load fallback fix (#162)

---------

Co-authored-by: Logan <vaegreen@outlook.com>
Co-authored-by: bob <dutifulbob@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cursor ACP session/load fallback not triggered due to unrecognized error code

3 participants