Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase view file size limit #852

Merged
merged 6 commits into from
Mar 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions codegen-examples/examples/swebench_agent_run/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env.db
6 changes: 3 additions & 3 deletions src/codegen/extensions/langchain/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ViewFileInput(BaseModel):
filepath: str = Field(..., description="Path to the file relative to workspace root")
start_line: int | None = Field(None, description="Starting line number to view (1-indexed, inclusive)")
end_line: int | None = Field(None, description="Ending line number to view (1-indexed, inclusive)")
max_lines: int | None = Field(None, description="Maximum number of lines to view at once, defaults to 250")
max_lines: int | None = Field(None, description="Maximum number of lines to view at once, defaults to 500")
line_numbers: bool | None = Field(True, description="If True, add line numbers to the content (1-indexed)")


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

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

return result.render()
Expand Down
2 changes: 1 addition & 1 deletion src/codegen/extensions/tools/reflection.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def perform_reflection(
# Initialize the LLM
llm = LLM(
model_provider="anthropic",
model_name="claude-3-5-sonnet-latest",
model_name="claude-3-7-sonnet-latest",
temperature=0.2, # Slightly higher temperature for more creative reflection
max_tokens=4000,
)
Expand Down
4 changes: 2 additions & 2 deletions src/codegen/extensions/tools/view_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def view_file(
line_numbers: bool = True,
start_line: Optional[int] = None,
end_line: Optional[int] = None,
max_lines: int = 250,
max_lines: int = 500,
) -> ViewFileObservation:
"""View the contents and metadata of a file.

Expand All @@ -88,7 +88,7 @@ def view_file(
line_numbers: If True, add line numbers to the content (1-indexed)
start_line: Starting line number to view (1-indexed, inclusive)
end_line: Ending line number to view (1-indexed, inclusive)
max_lines: Maximum number of lines to view at once, defaults to 250
max_lines: Maximum number of lines to view at once, defaults to 500
"""
try:
file = codebase.get_file(filepath)
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/codegen/extensions/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ def test_view_file_pagination(large_codebase):
result = view_file(large_codebase, "src/large_file.py")
assert result.status == "success"
assert result.start_line == 1
assert result.end_line == 250 # Default max_lines
assert result.end_line == 500 # Default max_lines
assert result.has_more is True
assert result.max_lines_per_page == 250
assert result.max_lines_per_page == 500
assert "from __future__ import annotations" in result.content # First line
assert "def method_1" in result.content # Early method
assert "def method_251" not in result.content # Method after page 1
Expand All @@ -141,8 +141,8 @@ def test_view_file_pagination(large_codebase):
assert result.has_more is True
assert "def method_69" in result.content # Regular method
assert "def class_method_80" in result.content # Class method at 80
# Should show 250 lines from start (350 to 599)
assert result.end_line == 599
# Should show 500 lines from start (350 to 849)
assert result.end_line == 849

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

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


def test_list_directory(codebase):
Expand Down
Loading