[BUG] Automatic file ingestion on pasted paths corrupts sessions and cannot be disabled
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
Summary
When a file path is pasted into Claude Code CLI, the application automatically ingests the file contents without user consent. This behavior:
- Cannot be disabled via CLAUDE.md instructions
- Cannot be overridden by explicit user instructions to Claude
- Permanently corrupts the session when the file is too large
Expected Behavior
File paths should be treated as strings unless the user explicitly asks Claude to read the file. The AI should decide whether to read a file, not the application layer.
Actual Behavior
The application intercepts file paths and force-feeds file contents to Claude before the AI has any opportunity to decide. When files are too large, every subsequent message returns:
"Image was too large. Double press esc to go back and try again with a smaller image."
The session cannot recover. Starting a new session loses all accumulated context.
Proof that user instructions don't help
I added this to CLAUDE.md: "Do NOT automatically read or ingest files when file paths are mentioned or pasted in the conversation."
I also explicitly told Claude in the conversation not to ingest files. Claude acknowledged and agreed. Then I pasted a file path, and the application ingested it anyway - because the application processes paths before Claude ever sees the message.
Impact
- Lost hours of session context and conversation history
- No workaround exists
Environment
- Claude Code version: 2.0.56
- macOS
What Should Happen?
File paths should be treated as strings unless the user explicitly asks Claude to read the file. The AI should decide whether to read a file, not the application layer.
Error Messages/Logs
What would you like to work on?
> IMPORTANT: Do NOT automatically read or ingest image files when I paste file paths. If I paste something like /path/to/image.png, treat it as a STRING - a file path
reference - not as an instruction to read the binary contents of that file. Only read image files if I explicitly ask you to with clear language like "read this image" or
"look at this screenshot".
The previous session was destroyed because Claude Code automatically ingested a PNG file I referenced, the file was too large, and the application corrupted itself into an
unrecoverable error loop.
You can also add this to your CLAUDE.md file in that workspace so it persists across all future sessions:
## IMPORTANT: Image File Handling
Do NOT automatically read or ingest image/binary files when file paths are mentioned or pasted. Treat file paths as strings unless explicitly instructed to read the file
contents. The previous session was corrupted by unsolicited image file ingestion.
This puts the instruction in a place where every new session in that workspace will see it.
⏺ Understood. I'll treat file paths as string references, not as instructions to read the file contents. I'll only read image/binary files when you explicitly ask me to.
Would you like me to add this instruction to the CLAUDE.md file so it persists across future sessions? I can append a section about image file handling to
/Users/[xxxx]/git/github.com/[xxxx]/CLAUDE.md.
> Actually, update this directive with ALL file paths, not just "image" files or "png" files
⏺ Got it. Would you like me to update the CLAUDE.md file with a broader directive that applies to all file paths - only reading files when you explicitly ask me to, rather
than automatically reading any file path that appears in the conversation?
> yes
⏺ Read(CLAUDE.md)
⎿ Read 127 lines
⏺ Update(CLAUDE.md)
⎿ Updated CLAUDE.md with 6 additions
1 + ## IMPORTANT: File Path Handling
2 +
3 + Do NOT automatically read or ingest files when file paths are mentioned or pasted in the conversation. Treat file paths as strings unless I explicitly ask you
+ to read the file contents with clear language like "read this file" or "look at this file". Only read files when explicitly instructed.
4 +
5 + ---
6 +
7
8
9 This document provides context for Claude AI sessions working on this project ecosystem.
Tip: Use # to memorize shortcut to quickly add to CLAUDE.md
⏺ Done. The CLAUDE.md file now has a directive at the top that applies to all file paths, not just images. Future sessions will see this instruction and won't automatically
read files unless you explicitly ask.
> [Image: original 4096x4096, displayed at 2000x2000. Multiply coordinates by 2.05 to map to original image.]
> [Image #1] I have given you the FILESYSTEM PATH string to a png file. Please compose and execute an astc command-line command that converts this png file to 6x6 astc
texture.
⏺ Image was too large. Double press esc to go back and try again with a smaller image.
Steps to Reproduce
- Open Claude Code CLI in any workspace
- Paste a path to a large PNG file (e.g., 4096x4096)
- The application automatically reads the file bytes before Claude sees the message
- If the file is too large, the session enters an unrecoverable error loop
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
No response
Claude Code Version
2.0.64 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
No response
Found 3 possible duplicate issues:
- https://github.com/anthropics/claude-code/issues/13179
- https://github.com/anthropics/claude-code/issues/13049
- https://github.com/anthropics/claude-code/issues/13421
This issue will be automatically closed as a duplicate in 3 days.
- If your issue is a duplicate, please close it and 👍 the existing issue instead
- To prevent auto-closure, add a comment or 👎 this comment
🤖 Generated with Claude Code
My issue is unique. The three "possible duplicates" describe an issue in which Claude Code breaks an entire session if it is asked to ingest a file that is too large.
Conversely, MY ticket is about Claude Code automatically ingesting files, even though I do NOT WANT it to ingest said files. In my example, I explicitly tell Claude Code NOT to ingest files when I paste file path STRINGS into Claude Code. In my example, I pasted a local macOS file path string, that I copied from a simple .txt file, into Claude Code cli. Within the same line, I told Claude Code to run an external, NON_CLAUDE, command-line program, and pass along the file path STRING, as an argument, to the external program, within a simple command-line, bash command. It seems that any time I paste a file path STRING into Claude Code, no matter the context or instruction, Claude Code will automatically ingest the actual file BYTES of the FILE itself. This is very undesirable behavior. I DO NOT WANT Claude Code to "parse" the bytes of files, unless I explicitly ask it to do so. A file path STRING (especially one that points to a BINARY file of N bytes) is NOT, in a any way, an invitation to open and read said file. This current, undesirable behavior makes little sense, especially since Claude Code CLI is meant for people who understand what file path strings are, as opposed to people who wish to DRAG file icons into Claude Code CLI. Regarding the potential duplicate issues: It does just so happen that ONE of the unpleasant results of THIS bug is that the current session will completely break when this happens. That 'result' is what is described in the three "potential duplicate" bugs. However, this bug, and those three bugs, are NOT describing the same underlying issue.