Skip to content

fix: allow partial args through parseToolCall finalization to enable proper retry behavior#12080

Draft
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/write-to-file-missing-content-12079
Draft

fix: allow partial args through parseToolCall finalization to enable proper retry behavior#12080
roomote-v0[bot] wants to merge 1 commit intomainfrom
fix/write-to-file-missing-content-12079

Conversation

@roomote-v0
Copy link
Copy Markdown
Contributor

@roomote-v0 roomote-v0 bot commented Apr 8, 2026

Related GitHub Issue

Closes: #12079

Description

This PR attempts to address Issue #12079 where write_to_file intermittently fails because the model's response gets truncated (e.g., due to output token limits), causing the required content parameter to arrive as undefined.

Root cause: In NativeToolCallParser.parseToolCall(), the finalization path for write_to_file (and other multi-required-param tools) used AND conditions requiring ALL parameters to be present before setting nativeArgs. When any required param was missing, nativeArgs stayed undefined, causing either a silent drop (null return) or a generic error -- bypassing the tool's own user-friendly retry logic in WriteToFileTool.execute().

Fix: Changed the AND conditions to OR conditions in the finalization path, matching the pattern already used in the streaming/partial path. This allows partially-constructed args to flow through to the tool's execute() method, which can produce specific "Roo tried to use write_to_file without value for required parameter 'content'. Retrying..." messages that get sent back to the model for self-correction.

Affected tools: write_to_file, apply_diff, edit/search_and_replace, search_replace, edit_file, ask_followup_question, generate_image, search_files, switch_mode, use_mcp_tool, access_mcp_resource, new_task.

Feedback and guidance are welcome.

Test Procedure

  • Added tests in NativeToolCallParser.spec.ts for write_to_file with missing content, missing path, and both present
  • Added test for apply_diff with missing diff
  • All 16 tests pass: cd src && npx vitest run core/assistant-message/__tests__/NativeToolCallParser.spec.ts
  • Lint, prettier, and type-check all pass (verified via git hooks)

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 required (internal behavior fix).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

Additional Notes

The streaming/partial path in the same file already uses OR conditions (e.g., line 468: if (partialArgs.path || partialArgs.content)). This change aligns the finalization path with that existing pattern. The fix is defensive -- each tool's execute() method already has per-parameter validation that produces actionable retry messages, but that validation was unreachable when nativeArgs was never constructed.

Interactively review PR in Roo Code Cloud

…to_file and other tools

When the model response gets truncated (e.g., due to output token limits),
required parameters like `content` for write_to_file arrive as `undefined`.
The finalization path in parseToolCall() required ALL params via AND conditions,
causing nativeArgs to stay undefined and the tool call to be silently dropped
or throw a generic error -- bypassing the tool's own user-friendly retry logic.

The streaming/partial path already uses OR conditions to allow partial args
through. This change aligns the finalization path with the same pattern,
so that partially-constructed args flow through to the tool's execute() method,
which can produce specific "missing parameter X, retrying..." messages that
get sent back to the model.

Fixes #12079
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.

[BUG] Intermittent failure: write_to_file called without required content parameter

1 participant