From c7c56bd5a5783f4e22eb7e688f3302987713fefd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E0=AE=AE=E0=AE=A9=E0=AF=8B=E0=AE=9C=E0=AF=8D=E0=AE=95?= =?UTF-8?q?=E0=AF=81=E0=AE=AE=E0=AE=BE=E0=AE=B0=E0=AF=8D=20=E0=AE=AA?= =?UTF-8?q?=E0=AE=B4=E0=AE=A9=E0=AE=BF=E0=AE=9A=E0=AF=8D=E0=AE=9A=E0=AE=BE?= =?UTF-8?q?=E0=AE=AE=E0=AE=BF?= Date: Sat, 19 Oct 2024 07:44:13 +0530 Subject: [PATCH] Fix file not found error in file_ops.py --- openhands/runtime/plugins/agent_skills/file_ops/file_ops.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/openhands/runtime/plugins/agent_skills/file_ops/file_ops.py b/openhands/runtime/plugins/agent_skills/file_ops/file_ops.py index a9a7c4c447f..832d449efa1 100644 --- a/openhands/runtime/plugins/agent_skills/file_ops/file_ops.py +++ b/openhands/runtime/plugins/agent_skills/file_ops/file_ops.py @@ -92,6 +92,8 @@ def _check_current_file(file_path: str | None = None) -> bool: file_path = CURRENT_FILE if not file_path or not os.path.isfile(file_path): return _output_error('No file open. Use the open_file function first.') + if not os.path.exists(file_path): + return _output_error(f'File {file_path} not found.') return True @@ -122,7 +124,8 @@ def _print_window( file_path, targeted_line, window, return_str=False, ignore_window=False ): global CURRENT_LINE - _check_current_file(file_path) + if not _check_current_file(file_path): + return with open(file_path) as file: content = file.read()