Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 21, 2025

Summary

This PR attempts to address Issue #10239, specifically @pwilkin's comment about unifying the line_range vs line_ranges parameter.

Problem

There was inconsistency between XML and Native protocol formats for the read_file tool:

  • XML Mode: Uses line_range (singular) with format "1-50"
  • Native Mode: Used line_ranges (plural) with JSON array format [[1, 50], [100, 150]]

This inconsistency could confuse models, especially when giving continuation instructions after file truncation.

Solution

Unified the native mode to use the same simpler format as XML mode:

  • Parameter name: Changed from line_ranges to line_range (singular)
  • Format: Changed from JSON array [[1, 50], [100, 150]] to string "1-50,100-150"
  • Backward compatibility: The parser still accepts the old array format for existing integrations

Changes

  1. src/core/prompts/tools/native-tools/read_file.ts: Updated tool definition to use line_range (string) instead of line_ranges (array)

  2. src/core/assistant-message/NativeToolCallParser.ts: Added parsing support for the new unified string format while maintaining backward compatibility with legacy formats

  3. Tests: Updated all related tests for the new format

Examples

Before (native mode):

{ "files": [{ "path": "src/app.ts", "line_ranges": [[1, 50], [100, 150]] }] }

After (native mode):

{ "files": [{ "path": "src/app.ts", "line_range": "1-50,100-150" }] }

This matches XML mode:

<file>
  <path>src/app.ts</path>
  <line_range>1-50</line_range>
  <line_range>100-150</line_range>
</file>

Feedback and guidance are welcome!

This PR addresses Issue #10239 by unifying the line_range parameter format
between XML and Native protocols:

- XML mode: line_range (singular) with format "1-50"
- Native mode: NOW uses line_range (singular) with format "1-50" or "1-50,100-150"

Previously native mode used line_ranges (plural) with JSON array format [[1,50],[100,150]].

Changes:
- Update native tool definition to use line_range (string) instead of line_ranges (array)
- Update NativeToolCallParser to handle both new and legacy formats for backward compatibility
- Update all related tests

The unified format makes it easier for models to understand and use incremental
file reading, especially for continuation after truncation.
@roomote
Copy link
Contributor Author

roomote bot commented Dec 21, 2025

Rooviewer Clock   See task on Roo Cloud

Review completed. No issues found.

The implementation is clean and well-tested:

  • Unified line_range parameter format between XML and Native protocols
  • Backward compatibility maintained for legacy formats
  • Comprehensive test coverage for all scenarios

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

3 participants