Skip to content

Commit 5a55008

Browse files
Increase view file size limit (#852)
# Motivation Window size for the ViewFile tool is too small # Content Increased the ViewFile tool window size to 500 # Testing Tested with swe bench # Please check the following before marking your PR as ready for review - [ ] I have added tests for my changes - [ ] I have updated the documentation or added new documentation as needed
1 parent c71f1f1 commit 5a55008

File tree

5 files changed

+13
-12
lines changed

5 files changed

+13
-12
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env.db

src/codegen/extensions/langchain/tools.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class ViewFileInput(BaseModel):
5454
filepath: str = Field(..., description="Path to the file relative to workspace root")
5555
start_line: int | None = Field(None, description="Starting line number to view (1-indexed, inclusive)")
5656
end_line: int | None = Field(None, description="Ending line number to view (1-indexed, inclusive)")
57-
max_lines: int | None = Field(None, description="Maximum number of lines to view at once, defaults to 250")
57+
max_lines: int | None = Field(None, description="Maximum number of lines to view at once, defaults to 500")
5858
line_numbers: bool | None = Field(True, description="If True, add line numbers to the content (1-indexed)")
5959

6060

@@ -63,7 +63,7 @@ class ViewFileTool(BaseTool):
6363

6464
name: ClassVar[str] = "view_file"
6565
description: ClassVar[str] = """View the contents and metadata of a file in the codebase.
66-
For large files (>250 lines), content will be paginated. Use start_line and end_line to navigate through the file.
66+
For large files (>500 lines), content will be paginated. Use start_line and end_line to navigate through the file.
6767
The response will indicate if there are more lines available to view."""
6868
args_schema: ClassVar[type[BaseModel]] = ViewFileInput
6969
codebase: Codebase = Field(exclude=True)
@@ -85,7 +85,7 @@ def _run(
8585
line_numbers=line_numbers if line_numbers is not None else True,
8686
start_line=start_line,
8787
end_line=end_line,
88-
max_lines=max_lines if max_lines is not None else 250,
88+
max_lines=max_lines if max_lines is not None else 500,
8989
)
9090

9191
return result.render()

src/codegen/extensions/tools/reflection.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def perform_reflection(
188188
# Initialize the LLM
189189
llm = LLM(
190190
model_provider="anthropic",
191-
model_name="claude-3-5-sonnet-latest",
191+
model_name="claude-3-7-sonnet-latest",
192192
temperature=0.2, # Slightly higher temperature for more creative reflection
193193
max_tokens=4000,
194194
)

src/codegen/extensions/tools/view_file.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def view_file(
7878
line_numbers: bool = True,
7979
start_line: Optional[int] = None,
8080
end_line: Optional[int] = None,
81-
max_lines: int = 250,
81+
max_lines: int = 500,
8282
) -> ViewFileObservation:
8383
"""View the contents and metadata of a file.
8484
@@ -88,7 +88,7 @@ def view_file(
8888
line_numbers: If True, add line numbers to the content (1-indexed)
8989
start_line: Starting line number to view (1-indexed, inclusive)
9090
end_line: Ending line number to view (1-indexed, inclusive)
91-
max_lines: Maximum number of lines to view at once, defaults to 250
91+
max_lines: Maximum number of lines to view at once, defaults to 500
9292
"""
9393
try:
9494
file = codebase.get_file(filepath)

tests/unit/codegen/extensions/test_tools.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ def test_view_file_pagination(large_codebase):
114114
result = view_file(large_codebase, "src/large_file.py")
115115
assert result.status == "success"
116116
assert result.start_line == 1
117-
assert result.end_line == 250 # Default max_lines
117+
assert result.end_line == 500 # Default max_lines
118118
assert result.has_more is True
119-
assert result.max_lines_per_page == 250
119+
assert result.max_lines_per_page == 500
120120
assert "from __future__ import annotations" in result.content # First line
121121
assert "def method_1" in result.content # Early method
122122
assert "def method_251" not in result.content # Method after page 1
@@ -141,8 +141,8 @@ def test_view_file_pagination(large_codebase):
141141
assert result.has_more is True
142142
assert "def method_69" in result.content # Regular method
143143
assert "def class_method_80" in result.content # Class method at 80
144-
# Should show 250 lines from start (350 to 599)
145-
assert result.end_line == 599
144+
# Should show 500 lines from start (350 to 849)
145+
assert result.end_line == 849
146146

147147
# Test custom max_lines
148148
result = view_file(large_codebase, "src/large_file.py", max_lines=100)
@@ -191,13 +191,13 @@ def test_view_file_pagination_edge_cases(large_codebase):
191191
assert result.status == "success"
192192
assert result.start_line == 200
193193
# Should respect max_lines and file length
194-
assert result.end_line == min(200 + 250 - 1, 2010)
194+
assert result.end_line == min(200 + 500 - 1, 2010)
195195

196196
# Test negative start_line (should default to 1)
197197
result = view_file(large_codebase, "src/large_file.py", start_line=-10)
198198
assert result.status == "success"
199199
assert result.start_line == 1
200-
assert result.end_line == 250
200+
assert result.end_line == 500
201201

202202

203203
def test_list_directory(codebase):

0 commit comments

Comments
 (0)