[MODEL/BUG] Claude Haiku using absolute paths when it should prefer to use relative ones
Preflight Checklist
- [x] I have searched existing issues for similar behavior reports
- [x] This report does NOT contain sensitive information (API keys, passwords, etc.)
Type of Behavior Issue
Other unexpected behavior
What You Asked Claude to Do
I asked Claude Haiku to create files WITHIN THE CURRENT FOLDER.
What Claude Actually Did
This is very similar to #69636 but not exactly the same.
It used EXCAPED ABSOLUTE PATHS and created them in a path with random encodings.
Expected Behavior
It SHOULD use RELATIVE PATHS instead to ensure that it stays within THE CURRENT FOLDER.
Files Affected
[the ones in the encoded place]
I then merged the folders together resulting in
[the correct files once I told the AI of this]
Permission Mode
Accept Edits was ON (auto-accepting changes)
Can You Reproduce This?
Yes, every time with the same prompt
Steps to Reproduce
Ask it to create the file ./directory_a/this_txt_file.txt; most of the time it will do so because of this, as I mentioned in #69636.
If not, ask it to create a folder directory_a within the current dir, and it will use ABSOLUTE PATHS to do it. Then ask it to create a this_txt_file.txt file within directory_a, and it will do this.
For the issues to actually arise, the full absolute paths need to include spaces and be escaped. It doesn't usually use quotes, or if the tools are called with quotes, it won't work.
Per Claude Haiku.
The Write tool documentation says:
"file_path": "The absolute path to the file to write (must be absolute, not relative)"
So when creating files with the Write tool, I should use absolute paths. But I just created ./test_file.txt with a relative path, and it worked...
Claude Model
Haiku
Relevant Conversation
The Write tool documentation says:
"file_path": "The absolute path to the file to write (must be absolute, not relative)"
So when creating files with the Write tool, I should use absolute paths. But I just created ./test_file.txt with a relative path, and it worked...
Impact
Critical - Data loss or corrupted project
Claude Code Version
2.1.205 (Claude Code)
Platform
Anthropic API
Additional Context
My suggestion is to remove this system portion from the tools.
Instead, tell it that it can take either type and that IT should make the best decision; don't make the decisions for IT (the Model).