fix: improve write_to_file missing content error with actionable recovery hints#11796
Open
roomote[bot] wants to merge 1 commit intomainfrom
Open
fix: improve write_to_file missing content error with actionable recovery hints#11796roomote[bot] wants to merge 1 commit intomainfrom
roomote[bot] wants to merge 1 commit intomainfrom
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related GitHub Issue
Closes: #11795
Description
This PR attempts to address Issue #11795. Feedback and guidance are welcome.
When
write_to_fileis called without thecontentparameter (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:
writeToFileMissingContentError()toformatResponseinresponses.tsthat 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).WriteToFileTool.tsto use this new specific error instead of the genericsayAndCreateMissingParamErrorwhencontentis missing. The user-facing "say" message also now mentions output token limits.pathremains unchanged.Test Procedure
writeToFileTool.spec.ts:contentis missing (checks that it mentions "truncated" and "output token limits", and does NOT call the genericsayAndCreateMissingParamError).pathis missing.cd src && npx vitest run core/tools/__tests__/writeToFileTool.spec.tsPre-Submission Checklist
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