From fc71a356754a72d10fcf61173648043a1c2e4120 Mon Sep 17 00:00:00 2001 From: sharath <29162020+tnfssc@users.noreply.github.com> Date: Wed, 11 Jun 2025 14:44:10 +0000 Subject: [PATCH] fix(upload_file): swap parameters in upload_file calls for consistency across the codebase --- backend/agent/api.py | 4 ++-- backend/agent/tools/sb_files_tool.py | 6 +++--- backend/agent/tools/web_search_tool.py | 4 ++-- backend/sandbox/api.py | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/backend/agent/api.py b/backend/agent/api.py index 4f051a14..3be04065 100644 --- a/backend/agent/api.py +++ b/backend/agent/api.py @@ -977,9 +977,9 @@ async def initiate_agent_with_files( if hasattr(sandbox, 'fs') and hasattr(sandbox.fs, 'upload_file'): import inspect if inspect.iscoroutinefunction(sandbox.fs.upload_file): - await sandbox.fs.upload_file(target_path, content) + await sandbox.fs.upload_file(content, target_path) else: - sandbox.fs.upload_file(target_path, content) + sandbox.fs.upload_file(content, target_path) logger.debug(f"Called sandbox.fs.upload_file for {target_path}") upload_successful = True else: diff --git a/backend/agent/tools/sb_files_tool.py b/backend/agent/tools/sb_files_tool.py index 3e86fb3d..34f33496 100644 --- a/backend/agent/tools/sb_files_tool.py +++ b/backend/agent/tools/sb_files_tool.py @@ -135,7 +135,7 @@ class SandboxFilesTool(SandboxToolsBase): self.sandbox.fs.create_folder(parent_dir, "755") # Write the file content - self.sandbox.fs.upload_file(full_path, file_contents.encode()) + self.sandbox.fs.upload_file(file_contents.encode(), full_path) self.sandbox.fs.set_file_permissions(full_path, permissions) message = f"File '{file_path}' created successfully." @@ -219,7 +219,7 @@ class SandboxFilesTool(SandboxToolsBase): # Perform replacement new_content = content.replace(old_str, new_str) - self.sandbox.fs.upload_file(full_path, new_content.encode()) + self.sandbox.fs.upload_file(new_content.encode(), full_path) # Show snippet around the edit replacement_line = content.split(old_str)[0].count('\n') @@ -294,7 +294,7 @@ class SandboxFilesTool(SandboxToolsBase): if not self._file_exists(full_path): return self.fail_response(f"File '{file_path}' does not exist. Use create_file to create a new file.") - self.sandbox.fs.upload_file(full_path, file_contents.encode()) + self.sandbox.fs.upload_file(file_contents.encode(), full_path) self.sandbox.fs.set_file_permissions(full_path, permissions) message = f"File '{file_path}' completely rewritten successfully." diff --git a/backend/agent/tools/web_search_tool.py b/backend/agent/tools/web_search_tool.py index 8dc6dfbc..b835b35d 100644 --- a/backend/agent/tools/web_search_tool.py +++ b/backend/agent/tools/web_search_tool.py @@ -353,8 +353,8 @@ class SandboxWebSearchTool(SandboxToolsBase): logging.info(f"Saving content to file: {results_file_path}, size: {len(json_content)} bytes") self.sandbox.fs.upload_file( - results_file_path, - json_content.encode() + json_content.encode(), + results_file_path, ) return { diff --git a/backend/sandbox/api.py b/backend/sandbox/api.py index f937361d..ccc59267 100644 --- a/backend/sandbox/api.py +++ b/backend/sandbox/api.py @@ -166,7 +166,7 @@ async def create_file( content = await file.read() # Create file using raw binary content - sandbox.fs.upload_file(path, content) + sandbox.fs.upload_file(content, path) logger.info(f"File created at {path} in sandbox {sandbox_id}") return {"status": "success", "created": True, "path": path}