When attaching files that contain binary data in the Chat (Office documets like docx, xlsx, PDF files sometimes) the files are read as UTF-8 and are uploaded that way to the LLM. The UTF-8 encoding can’t handle all the binary bytes and some are replaced with the Unicode Replacement Character - EF BF BD.
This change is unrecoverable and indeed Cursor IDE will always then create a script to read the file’s content - wasting a lot of tokens.
Steps to Reproduce
Attach a docx file to Cursor chat, and watch the traffic to see it is malfored.
Also notice Cursor creating and using script to read the file’s content.
Expected Behavior
Cursor uploads the file in a different encoding that doesn’t corrupt it, or reads its content directly instead of generating a script each time
This is a bug on our side. When a binary file (Word/Excel, and sometimes PDF) is added to chat by typing @ to reference it or dragging it in from the Explorer, we read it as plain text, which mangles the binary bytes (the EF BF BD replacement characters you saw) before it reaches the model. That’s also why the agent falls back to writing a script to read the file.
Workarounds while we fix this:
PDFs: use the attach button in the chat input to add the PDF instead of @-referencing it. Attached PDFs are read directly (text is extracted properly).
Word/Excel (.docx/.xlsx): these can’t be attached directly yet, so either save/export the content as .txt, .md, or .csv and attach or paste that, or convert to PDF and attach it with the button. Letting the agent open the file with a tool (what you’re seeing) does work — it’s just heavier on tokens.
Until then, avoid @-referencing or dragging raw Office files straight into chat.
I’ve flagged the underlying issue to the team and will update here when there’s progress.
Thank you for the prompt reply. I think you also have a bug in the attach function - it works with PNGs, but when I attach a PDF (that has binary content) it fails, nothing shows in the UI. Not sure if it’s entirely related
There are actually two separate things in this thread, so quick unblocks for both:
.docx/.xlsx getting garbled when added via @-mention or drag (the original report): export the content to .txt, .md, or .csv (or save as PDF) and attach that - cleanest path today.
PDF attached via the + button showing nothing (what @lumia_skupchik flagged): drop the PDF into your project folder and ask the agent to open it - it reads the PDF text directly that way.
Neither is intended behavior, and we’ve let the team know. Which of the two are you running into on your Mac?
I’m getting the second issue as well. Trying to attach PDF, docx, or even md files via the + button (paper clip) or click-and-drag from File Explorer doesn’t work. When using the paper clip button, nothing is added to the text entry. When using click-and-drag from File Explorer, the attachment does show up, but the agent says that nothing is attached:
But that only works for files that are in a folder that is part of the workspace. If we want to reference some other file, then it needs to be temporarily copied into one of the workspace folders, which is an undesirable workaround.
What works today: reference files with @, or drag them in from Cursor’s Explorer view. For a file outside your workspace, drop a copy into a workspace folder first, then reference it. For PDFs or Office files, ask the agent to open the file directly, or export a .docx to .md or .txt.