diff --git a/backend/agent/tools/sb_files_tool.py b/backend/agent/tools/sb_files_tool.py
index bae22dbb..d907fd71 100644
--- a/backend/agent/tools/sb_files_tool.py
+++ b/backend/agent/tools/sb_files_tool.py
@@ -298,100 +298,107 @@ class SandboxFilesTool(SandboxToolsBase):
except Exception as e:
return self.fail_response(f"Error deleting file: {str(e)}")
- @openapi_schema({
- "type": "function",
- "function": {
- "name": "read_file",
- "description": "Read and return the contents of a file. This tool is essential for verifying data, checking file contents, and analyzing information. Always use this tool to read file contents before processing or analyzing data. The file path must be relative to /workspace.",
- "parameters": {
- "type": "object",
- "properties": {
- "file_path": {
- "type": "string",
- "description": "Path to the file to read, relative to /workspace (e.g., 'src/main.py' for /workspace/src/main.py). Must be a valid file path within the workspace."
- },
- "start_line": {
- "type": "integer",
- "description": "Optional starting line number (1-based). Use this to read specific sections of large files. If not specified, reads from the beginning of the file.",
- "default": 1
- },
- "end_line": {
- "type": "integer",
- "description": "Optional ending line number (inclusive). Use this to read specific sections of large files. If not specified, reads to the end of the file.",
- "default": None
- }
- },
- "required": ["file_path"]
- }
- }
- })
- @xml_schema(
- tag_name="read-file",
- mappings=[
- {"param_name": "file_path", "node_type": "attribute", "path": "."},
- {"param_name": "start_line", "node_type": "attribute", "path": ".", "required": False},
- {"param_name": "end_line", "node_type": "attribute", "path": ".", "required": False}
- ],
- example='''
-
-
-
+ # @openapi_schema({
+ # "type": "function",
+ # "function": {
+ # "name": "read_file",
+ # "description": "Read and return the contents of a file. This tool is essential for verifying data, checking file contents, and analyzing information. Always use this tool to read file contents before processing or analyzing data. The file path must be relative to /workspace.",
+ # "parameters": {
+ # "type": "object",
+ # "properties": {
+ # "file_path": {
+ # "type": "string",
+ # "description": "Path to the file to read, relative to /workspace (e.g., 'src/main.py' for /workspace/src/main.py). Must be a valid file path within the workspace."
+ # },
+ # "start_line": {
+ # "type": "integer",
+ # "description": "Optional starting line number (1-based). Use this to read specific sections of large files. If not specified, reads from the beginning of the file.",
+ # "default": 1
+ # },
+ # "end_line": {
+ # "type": "integer",
+ # "description": "Optional ending line number (inclusive). Use this to read specific sections of large files. If not specified, reads to the end of the file.",
+ # "default": None
+ # }
+ # },
+ # "required": ["file_path"]
+ # }
+ # }
+ # })
+ # @xml_schema(
+ # tag_name="read-file",
+ # mappings=[
+ # {"param_name": "file_path", "node_type": "attribute", "path": "."},
+ # {"param_name": "start_line", "node_type": "attribute", "path": ".", "required": False},
+ # {"param_name": "end_line", "node_type": "attribute", "path": ".", "required": False}
+ # ],
+ # example='''
+ #
+ #
+ #
-
-
-
+ #
+ #
+ #
-
-
-
+ #
+ #
+ #
-
-
-
- '''
- )
- async def read_file(self, file_path: str, start_line: int = 1, end_line: Optional[int] = None) -> ToolResult:
- """Read file content with optional line range specification.
+ #
+ #
+ #
+ # '''
+ # )
+ # async def read_file(self, file_path: str, start_line: int = 1, end_line: Optional[int] = None) -> ToolResult:
+ # """Read file content with optional line range specification.
- Args:
- file_path: Path to the file relative to /workspace
- start_line: Starting line number (1-based), defaults to 1
- end_line: Ending line number (inclusive), defaults to None (end of file)
+ # Args:
+ # file_path: Path to the file relative to /workspace
+ # start_line: Starting line number (1-based), defaults to 1
+ # end_line: Ending line number (inclusive), defaults to None (end of file)
- Returns:
- ToolResult containing:
- - Success: File content and metadata
- - Failure: Error message if file doesn't exist or is binary
- """
- try:
- file_path = self.clean_path(file_path)
- full_path = f"{self.workspace_path}/{file_path}"
+ # Returns:
+ # ToolResult containing:
+ # - Success: File content and metadata
+ # - Failure: Error message if file doesn't exist or is binary
+ # """
+ # try:
+ # file_path = self.clean_path(file_path)
+ # full_path = f"{self.workspace_path}/{file_path}"
- if not self._file_exists(full_path):
- return self.fail_response(f"File '{file_path}' does not exist")
+ # if not self._file_exists(full_path):
+ # return self.fail_response(f"File '{file_path}' does not exist")
- # Download and decode file content
- content = self.sandbox.fs.download_file(full_path).decode()
+ # # Download and decode file content
+ # content = self.sandbox.fs.download_file(full_path).decode()
- # Handle line range if specified
- if start_line > 1 or end_line is not None:
- lines = content.split('\n')
- start_idx = max(0, start_line - 1) # Convert to 0-based index
- end_idx = end_line if end_line is not None else len(lines)
- content = '\n'.join(lines[start_idx:end_idx])
+ # # Split content into lines
+ # lines = content.split('\n')
+ # total_lines = len(lines)
- return self.success_response({
- "content": content,
- "file_path": file_path,
- "start_line": start_line,
- "end_line": end_line if end_line is not None else len(content.split('\n')),
- "total_lines": len(content.split('\n'))
- })
+ # # Handle line range if specified
+ # if start_line > 1 or end_line is not None:
+ # # Convert to 0-based indices
+ # start_idx = max(0, start_line - 1)
+ # end_idx = end_line if end_line is not None else total_lines
+ # end_idx = min(end_idx, total_lines) # Ensure we don't exceed file length
+
+ # # Extract the requested lines
+ # content = '\n'.join(lines[start_idx:end_idx])
- except UnicodeDecodeError:
- return self.fail_response(f"File '{file_path}' appears to be binary and cannot be read as text")
- except Exception as e:
- return self.fail_response(f"Error reading file: {str(e)}")
+ # return self.success_response({
+ # "content": content,
+ # "file_path": file_path,
+ # "start_line": start_line,
+ # "end_line": end_line if end_line is not None else total_lines,
+ # "total_lines": total_lines
+ # })
+
+ # except UnicodeDecodeError:
+ # return self.fail_response(f"File '{file_path}' appears to be binary and cannot be read as text")
+ # except Exception as e:
+ # return self.fail_response(f"Error reading file: {str(e)}")
async def test_files_tool():