Skip to content

fix: improve write_to_file missing content error with actionable recovery hints#11796

Open
roomote[bot] wants to merge 1 commit intomainfrom
fix/write-to-file-missing-content-error-11795
Open

fix: improve write_to_file missing content error with actionable recovery hints#11796
roomote[bot] wants to merge 1 commit intomainfrom
fix/write-to-file-missing-content-error-11795

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Feb 28, 2026

Related GitHub Issue

Closes: #11795

Description

This PR attempts to address Issue #11795. Feedback and guidance are welcome.

When write_to_file is called without the content parameter (typically due to output token truncation when generating large files via a proxy), the error feedback sent back to the model was generic: just "Missing value for required parameter 'content'. Please retry with complete response." This gave the model no useful context, so it would retry the exact same approach and hit the same token limit again, looping until the consecutive mistake limit (default: 3) was reached.

Changes:

  • Added writeToFileMissingContentError() to formatResponse in responses.ts that provides a specific, actionable error message explaining the likely cause (output token truncation) and suggesting concrete recovery strategies (create a smaller file first and extend with edit_file, use edit_file for targeted changes, or split into multiple files).
  • Updated WriteToFileTool.ts to use this new specific error instead of the generic sayAndCreateMissingParamError when content is missing. The user-facing "say" message also now mentions output token limits.
  • The generic missing-parameter error path for path remains unchanged.

Test Procedure

  • Added 2 new test cases in writeToFileTool.spec.ts:
    1. Verifies the enhanced error message is used when content is missing (checks that it mentions "truncated" and "output token limits", and does NOT call the generic sayAndCreateMissingParamError).
    2. Verifies the generic error path still works correctly when path is missing.
  • All 26 tests pass: cd src && npx vitest run core/tools/__tests__/writeToFileTool.spec.ts
  • Lint and type checks pass across the monorepo.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes.
  • Documentation Impact: No documentation updates needed -- this is an internal error message improvement.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

No documentation updates needed. This change only affects internal error messages sent to the LLM during tool execution.

Interactively review PR in Roo Code Cloud

…very hints

When write_to_file is called without the content parameter (typically due to
output token truncation on large files), the error feedback sent back to the
model was generic and unhelpful. The model would simply retry the same failing
approach, hitting the same token limit each time.

This change replaces the generic "missing parameter" error with a specific
message that:
- Explains the likely cause (output token truncation)
- Suggests concrete alternatives (create smaller file first, use edit_file,
  split into multiple files)
- Explicitly tells the model NOT to retry the same approach

Closes #11795
@roomote roomote bot marked this pull request as ready for review March 1, 2026 06:41
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Mar 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] write_to_file API keeps on failing and it stuck there

1 participant