Skip to content

Bug: insert_content fails to create missing files #3652

@KJ7LNW

Description

@KJ7LNW

Description

The insert_content tool fails when attempting to insert content into files that don't exist yet. This happens both when trying to append (line=0) and when trying to insert at the beginning (line=1).

Version Information

  • App Version: v3.17.1
  • API Provider: Anthropic
  • Model: Claude 3.7 Sonnet

Expected Behavior

The insert_content tool should be able to create missing files when:

  • Appending content (line=0)
  • Inserting at the beginning (line=1)

Similar to how write_to_file creates missing files and directories.

Actual Behavior

The tool returns an error: "File does not exist at path: [filepath]"

Steps to Reproduce

  1. Try to use insert_content on a non-existent file with line=0 (append)
  2. Try to use insert_content on a non-existent file with line=1 (insert at beginning)

Error Messages

File does not exist at path: /home/ewheeler/src/roo/Roo2/test_nonexistent_append.txt

The specified file could not be found. Please verify the file path and try again.

Additional Context

This limitation reduces the flexibility of the insert_content tool. Users must first create empty files with write_to_file before they can use insert_content, which adds unnecessary steps to the workflow.

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions