FoundationAgents/OpenManus · error · ToolError
Invalid `view_range`: {view_range}. Its second element `{fin
Error message
Invalid `view_range`: {view_range}. Its second element `{final_line}` should be larger or equal than its first `{init_line}` What it means
Error "Invalid `view_range`: {view_range}. Its second element `{final_line}` should be larger or equal than its first `{init_line}`" thrown in FoundationAgents/OpenManus.
Source
Thrown at app/tool/str_replace_editor.py:268
)
file_lines = file_content.split("\n")
n_lines_file = len(file_lines)
init_line, final_line = view_range
# Validate view range
if init_line < 1 or init_line > n_lines_file:
raise ToolError(
f"Invalid `view_range`: {view_range}. Its first element `{init_line}` should be "
f"within the range of lines of the file: {[1, n_lines_file]}"
)
if final_line > n_lines_file:
raise ToolError(
f"Invalid `view_range`: {view_range}. Its second element `{final_line}` should be "
f"smaller than the number of lines in the file: `{n_lines_file}`"
)
if final_line != -1 and final_line < init_line:
raise ToolError(
f"Invalid `view_range`: {view_range}. Its second element `{final_line}` should be "
f"larger or equal than its first `{init_line}`"
)
# Apply range
if final_line == -1:
file_content = "\n".join(file_lines[init_line - 1 :])
else:
file_content = "\n".join(file_lines[init_line - 1 : final_line])
# Format and return result
return CLIResult(
output=self._make_output(file_content, str(path), init_line=init_line)
)
async def str_replace(
self,
path: PathLike,View on GitHub (pinned to 52a13f2a57)
Solutions
- Ensure the second element of `view_range` is greater than or equal to the first element, e.g. [10, 20] not [20, 10].
When it happens
Trigger: Raised when the second element of `view_range` is smaller than the first element (and is not -1).
Common situations: See trigger scenarios.
AI-assisted analysis of FoundationAgents/OpenManus@52a13f2a57 (2026-08-15).
Data as JSON: /api/errors/71773dbf91684bf1.
Report an issue: GitHub.