Session not found error when opening previous conversations in Cursor (exit code 1)
Environment
- Claude Code extension version: 2.1.27
- Editor: Cursor 2.4.27 (arm64)
- OS: macOS 26.3 (Build 25D5112c)
Description
When attempting to open or resume previous conversations in the Claude Code VSCode/Cursor extension, the process fails with "session not found" followed by exit code 1. New conversations work fine — this only affects past conversations.
Additionally, the sessions-index.json was out of sync with session files on disk (1 entry indexed vs 6 .jsonl files present), which may be related.
Steps to Reproduce
- Have existing Claude Code conversations in a project
- Close Cursor
- Reopen Cursor and attempt to resume/access a previous conversation
- Error: "session not found", then process exits with code 1
Logs
MCP connection errors (observed during session)
2026-02-02 21:43:29.721 [info] From claude: 2026-02-02T21:43:29.721Z [DEBUG] MCP server "n8n-docs": STDIO connection dropped after 0s uptime
2026-02-02T21:43:29.721Z [DEBUG] MCP server "n8n-docs": Connection error: JSON Parse error: Single quotes (') are not allowed in JSON
2026-02-02T21:43:29.721Z [DEBUG] MCP server "n8n-docs": STDIO connection dropped after 0s uptime
2026-02-02T21:43:29.721Z [DEBUG] MCP server "n8n-docs": Connection error: JSON Parse error: Single quotes (') are not allowed in JSON
2026-02-02T21:43:29.721Z [DEBUG] MCP server "n8n-docs": STDIO connection dropped after 0s uptime
2026-02-02T21:43:29.721Z [DEBUG] MCP server "n8n-docs": Connection error: JSON Parse error: Single quotes (') are not allowed in JSON
2026-02-02T21:43:29.721Z [DEBUG] MCP server "n8n-docs": STDIO connection dropped after 0s uptime
2026-02-02T21:43:29.721Z [DEBUG] MCP server "n8n-docs": Connection error: JSON Parse error: Single quotes (') are not allowed in JSON
2026-02-02T21:43:29.721Z [DEBUG] MCP server "n8n-docs": STDIO connection dropped after 0s uptime
2026-02-02T21:43:29.721Z [DEBUG] MCP server "n8n-docs": Connection error: JSON Parse error: Single quotes (') are not allowed in JSON
API error when resuming session
When attempting to resume the old session, the API returned:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.0.content.0: unexpected `tool_use_id` found in `tool_result` blocks: toolu_01Dn5apfNApg3hjRcUzY1j3o. Each `tool_result` block must have a corresponding `tool_use` block in the previous message."},"request_id":"req_011CXjz2bHCHgMCUUckAcqrn"}
This suggests the session replay/reconstruction has orphaned tool_result blocks without matching tool_use blocks, causing the API to reject the conversation history.
Observations
- sessions-index.json out of sync: Only 1 of 6 session
.jsonlfiles was listed in the index. Manually rebuilding the index did not fix the resume error. - MCP crash loop: A misconfigured MCP server (
n8n-docs) was crash-looping with JSON parse errors. Even after disabling all MCPs and clearing MCP config, the session resume issue persisted. - Orphaned tool_result blocks: The root cause appears to be corrupted session history where
tool_resultblocks lost their correspondingtool_useblocks, making the conversation impossible to replay via the API.
What I've Tried
- Removing Cursor settings
- Disabling all MCP servers (backed up and emptied
~/.claude/mcp.json) - Removing session history / clearing session data
- Rebuilding
sessions-index.jsonto include all session files on disk - None of these resolved the "session not found" error for past conversations
Expected Behavior
Previous conversations should be accessible and resumable. If session data becomes corrupted (e.g., orphaned tool_result blocks), Claude Code should handle it gracefully — either by repairing the conversation history or showing a clear error rather than crashing with exit code 1.
Suggested Improvements
- Session repair: Automatically strip orphaned
tool_result/tool_useblocks before replaying history - Graceful degradation: Show a "this session cannot be resumed" message instead of crashing
- Index sync: Keep
sessions-index.jsonin sync with session files on disk - MCP isolation: Prevent MCP server failures from causing Claude Code to exit
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗