Issue: Cursor ACP session/load fallback not triggered due to unrecognized error code
Summary
Cursor CLI's ACP implementation returns error code -32602 (Invalid Params) with message "Session \"xxx\" not found" when session/load fails, but acpx's shouldFallbackToNewSession() only recognizes -32002 (Resource Not Found) or -32603 (Internal Error). This prevents the automatic fallback to session/new, causing all Cursor ACP sessions to fail when spawned through OpenClaw.
Steps to Reproduce
- Install Cursor CLI and authenticate:
agent login
- Install acpx:
npm install -g acpx@latest (v0.3.1)
- Try to spawn a Cursor ACP session through OpenClaw's
sessions_spawn(runtime="acp", agentId="cursor")
- Observe the error:
Invalid params - Session "xxx" not found
Alternatively, test directly:
cursor-agent acp <<'EOF'
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":1,"clientCapabilities":{"fs":{"readTextFile":true,"writeTextFile":true},"terminal":true},"clientInfo":{"name":"test","version":"1.0"}}}
{"jsonrpc":"2.0","id":2,"method":"session/load","params":{"sessionId":"nonexistent-session-id","cwd":"/tmp","mcpServers":[]}}
EOF
Response:
{"jsonrpc":"2.0","id":2,"error":{"code":-32602,"message":"Invalid params","data":{"message":"Session \"nonexistent-session-id\" not found"}}}
Expected Behavior
acpx should recognize this error as a "session not found" condition and fallback to session/new, creating a fresh session.
Actual Behavior
acpx throws RUNTIME: Invalid params - Session "xxx" not found and does not fallback.
Root Cause
In src/session-runtime/connect-load.ts, the shouldFallbackToNewSession() function checks:
function shouldFallbackToNewSession(error, record) {
if (error instanceof TimeoutError || error instanceof InterruptedError) return false;
if (isAcpResourceNotFoundError(error)) return true; // checks for -32002
if (!sessionHasAgentMessages(record)) {
if (isAcpQueryClosedBeforeResponseError(error)) return true;
if (extractAcpError(error)?.code === -32603) return true; // only -32603, not -32602
}
return false;
}
Cursor returns -32602 (Invalid Params), which doesn't match any condition.
Comparison with Similar Fixes
This is similar to the issues fixed in:
Cursor's error format differs from both:
- Error code:
-32602 (not -32603 or -32002)
- Error message:
"Session \"xxx\" not found" in data.message
Suggested Fix
Add text-based matching for Cursor's error message pattern, similar to PR #35. Options:
- Add
-32602 to fallback conditions when session has no agent messages
- Add text pattern matching for
"session" ... "not found" in error data
Example fix (option 2):
function isSessionNotFoundError(error) {
const acp = extractAcpError(error);
if (!acp) return false;
// Check error message in data
const data = acp.data;
if (data && typeof data.message === 'string') {
const msg = data.message.toLowerCase();
if (msg.includes('session') && msg.includes('not found')) {
return true;
}
}
return false;
}
function shouldFallbackToNewSession(error, record) {
if (error instanceof TimeoutError || error instanceof InterruptedError) return false;
if (isAcpResourceNotFoundError(error)) return true;
if (isSessionNotFoundError(error)) return true; // new check
// ... rest of function
}
Environment
- acpx version: 0.3.1
- Cursor CLI version: 2026.03.11-6dfa30c
- Cursor subscription: Pro
- OpenClaw version: latest (with acpx backend)
Workaround
Using acpx cursor exec directly works because it creates a fresh session without attempting session/load first.
Issue: Cursor ACP session/load fallback not triggered due to unrecognized error code
Summary
Cursor CLI's ACP implementation returns error code
-32602(Invalid Params) with message"Session \"xxx\" not found"whensession/loadfails, but acpx'sshouldFallbackToNewSession()only recognizes-32002(Resource Not Found) or-32603(Internal Error). This prevents the automatic fallback tosession/new, causing all Cursor ACP sessions to fail when spawned through OpenClaw.Steps to Reproduce
agent loginnpm install -g acpx@latest(v0.3.1)sessions_spawn(runtime="acp", agentId="cursor")Invalid params - Session "xxx" not foundAlternatively, test directly:
Response:
{"jsonrpc":"2.0","id":2,"error":{"code":-32602,"message":"Invalid params","data":{"message":"Session \"nonexistent-session-id\" not found"}}}Expected Behavior
acpx should recognize this error as a "session not found" condition and fallback to
session/new, creating a fresh session.Actual Behavior
acpx throws
RUNTIME: Invalid params - Session "xxx" not foundand does not fallback.Root Cause
In
src/session-runtime/connect-load.ts, theshouldFallbackToNewSession()function checks:Cursor returns
-32602(Invalid Params), which doesn't match any condition.Comparison with Similar Fixes
This is similar to the issues fixed in:
-32603+data.details: "Session not found"(Claude)"Invalid session identifier"(Gemini)Cursor's error format differs from both:
-32602(not-32603or-32002)"Session \"xxx\" not found"indata.messageSuggested Fix
Add text-based matching for Cursor's error message pattern, similar to PR #35. Options:
-32602to fallback conditions when session has no agent messages"session" ... "not found"in error dataExample fix (option 2):
Environment
Workaround
Using
acpx cursor execdirectly works because it creates a fresh session without attemptingsession/loadfirst.