fix: progressive error for write_to_file missing content to break retry loops#11909
Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
Draft
fix: progressive error for write_to_file missing content to break retry loops#11909roomote-v0[bot] wants to merge 1 commit intomainfrom
roomote-v0[bot] wants to merge 1 commit intomainfrom
Conversation
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: #11861
Description
This PR attempts to address Issue #11861, adapting the approach from cline/cline#9276 for Roo Code. Feedback and guidance are welcome.
Problem: When the model's output is truncated (due to output token limits or high context usage),
write_to_filetool calls arrive with an emptycontentparameter. The current error handler returns a generic "Missing value for required parameter content. Please retry with complete response." which the model interprets literally and retries identically, creating an infinite retry loop.Solution: Replace the generic missing parameter error for
write_to_filecontent with a progressive, tiered error message system:apply_diff/edit, break into smaller steps, write a skeleton firstwrite_to_file, required actions listedThe error also includes context window awareness -- when context usage exceeds 50%, the message warns the model that output capacity is reduced.
Changes
src/core/prompts/responses.ts-- AddedwriteToFileMissingContentError(relPath, failureCount, contextUsagePercent?)with tiered progressive guidancesrc/core/tools/WriteToFileTool.ts-- Replaced genericsayAndCreateMissingParamErrorfor missing content with the new specialized error, computing context window usage from API metricssrc/core/prompts/__tests__/writeToFileMissingContentError.spec.ts-- 21 unit tests covering all tiers and context window awarenesssrc/core/tools/__tests__/writeToFileTool.spec.ts-- Updated mocks to support the new error pathTest Procedure
All 45 tests passing (21 new + 24 existing).
Pre-Submission Checklist
Documentation Updates
Additional Notes
This adapts the approach from cline/cline#9276 for Roo Code, using Roo's tool names (
apply_diff,edit) instead of Cline's (replace_in_file) and integrating with Roo's existinggetApiMetricsutility andTaskarchitecture.Interactively review PR in Roo Code Cloud