Skip to content

Files with only newlines cannot be created using write_to_fileΒ #3533

@KJ7LNW

Description

@KJ7LNW

Version

v3.16.5

API Provider

Anthropic

Model

sonnet-3.5

What happened?

When attempting to create a file that contains only newlines (blank content) using the write_to_file tool, the operation fails. The file is not created.

Expected behavior: The write_to_file tool should successfully create files even when they contain only newlines without any visible text content.

Steps to reproduce

  1. Attempt to create a file using write_to_file with content that contains only newlines
  2. Example:
<write_to_file>
<path>test_file.txt</path>
<content>










</content>
<line_count>10</line_count>
</write_to_file>
  1. Observe that the file is not created or the operation fails

Relevant API REQUEST output

No specific error message was provided, but the file creation operation fails when the content contains only newlines.

Additional context

This issue appears to be related to how the write_to_file tool handles content that consists only of whitespace or newlines. It may be treating such content as empty or null, despite the fact that newlines are valid characters that should be preserved.

This affects workflows where users need to create template files or placeholders with specific line counts but no visible text content.

Metadata

Metadata

Labels

Issue - In ProgressSomeone is actively working on this. Should link to a PR soon.bugSomething isn't working

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions