I keep running into an issue in which Cursor Chat will remove/prune references to files (via @file) after the request is sent, resulting in the file contents not being read by the LLM in the response.
It’s gotten to the point where I encounter this issue multiple times per chat session and is easily the most glaring problem I’ve encountered with Cursor to date. It’s also a very subtle problem that’s easy to miss for new users- I only realized this was happening after LLM responses severely degraded in quality recently, only to discover it was because Cursor was removing half of the files I was attaching to its chat context.
From my limited knowledge, it appears to be a frontend/client-side issue rather than a backend issue, as Cursor appears to prune specific attached files from the request as it’s submitted in the chat client itself with no rhyme or reason. Despite being extremely hard to reproduce, I’ll to my best to elaborate with an example of this behavior:
Let’s say I start a new chat and write the following prompt with a few files attached:
@example-file-1.ts @example-file-2.ts @example-file-3.ts
Please describe the contents of "example-file-2.ts".
Despite the three files appearing to be properly attached, some appear to be sporadically pruned once the request is actually submitted:
@example-file-1.ts @example-file-3.ts
Please describe the contents of "example-file-2.ts".
This can also usually be confirmed in the LLM response, which will typically be something like:
I notice you've asked me to describe the contents of "example-file-2.ts".
However, you only provided "example-file-1.ts" and "example-file-2.ts".
I can't see any file contents unless you share them with me directly.
This can also be further confirmed by attempting to paste the contents of files into a new chat message- the contents of files that Cursor reads (i.e example-file-1.ts
, example-file-3.ts
) will result in the file’s context being automatically attached via the shortened @[filename]
macro, but problematic files like example-file-2.ts
that get omitted will just have their entire plaintext content pasted directly into the chat message box.
I’ll try to record a video showing the behavior when I get a chance.
For the sake of thoroughness, here’s absolutely every variable I’ve ruled out:
- Ensuring the files aren’t ignored in .gitignore or .cursorignore by ensuring Cursor can see the files in
Cursor Settings > Features > Codebase Indexing > Ignore Files > See all included files
) - Checking for filesystem permission issues or path related problems
- Ensuring the file contents and encodings are consistent/valid
- Trying different LLM API endpoints, through both Cursor’s Premium models and custom models using my own API keys
- Ensuring it’s not a context/token limit issue (happens in brand new chats with files of all sizes)
- Re-indexing the project in Cursor settings
Here’s some information about my environment:
- Cursor version: 0.42.4
- VSCode version: 1.93.1
- Commit: b1e87884330fc271d5eb589e368c35f14e76dec0
- Date: 2024-10-29T17:17:29.347Z (3 days ago)
- Electron: 30.4.0
- Chromium: 124.0.6367.243
- Node.js: 20.15.1
- V8: 12.4.254.20-electron.0
- OS: Darwin arm64 24.1.0 (MacOS 15.1.0 Sequoia)
The only potential variable I’ve noticed is that it seems to occur most often in projects that use javascript frameworks like Astro and Vue, although that might just be selection bias as that tends to be what I work with most often these days. Plus, I’ve seen this behavior with all matters of file extensions, from .txt
to .py
- not just .vue
or .astro
files.
Any ideas? Is this user error, or is this a commonly reported issue?