Skip to content

fix: prevent model from using shell scripts to modify file contents#11863

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/prevent-shell-script-file-writes
Draft

fix: prevent model from using shell scripts to modify file contents#11863
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/prevent-shell-script-file-writes

Conversation

@roomote-v0
Copy link
Contributor

@roomote-v0 roomote-v0 bot commented Mar 4, 2026

This PR attempts to address Issue #11861.

Problem

When write_to_file fails or seems unsuitable for large files, the model falls back to using execute_command to create shell scripts that modify file contents (via sed, echo, cat, printf, tee, etc.). This is problematic and was not observed when XML tooling was used.

Changes

  1. write_to_file tool description - Added explicit guidance naming apply_diff and edit as the preferred alternatives, plus a clear prohibition against using execute_command with shell commands as a workaround for file modifications.

  2. execute_command tool description - Added a prohibition against using this tool to modify file contents, directing the model to use the dedicated file editing tools instead.

Why prompt-level changes

The model resorts to shell scripts because nothing in the tool descriptions explicitly prevents it. Adding clear instructions at the prompt level steers the model toward the correct tools.

Feedback and guidance are welcome.

Interactively review PR in Roo Code Cloud

Add explicit prohibitions in write_to_file and execute_command tool
descriptions to prevent the model from falling back to shell scripts
(sed, echo, cat, printf, tee, etc.) when modifying file contents.

Instead, the model is directed to use the dedicated file editing tools
(apply_diff, edit, or write_to_file).

Closes #11861
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant