Skip to content

Agent Zero AI framework

Guard delete_file with exists check

frdel7bd3ab6afb13
diff --git a/python/helpers/files.py b/python/helpers/files.py
index 130c65dd2..2a21032ba 100644
--- a/python/helpers/files.py
+++ b/python/helpers/files.py
@@ -425,7 +425,8 @@ def write_file(relative_path: str, content: str, encoding: str = "utf-8"):
def delete_file(relative_path: str):
abs_path = get_abs_path(relative_path)
- os.remove(abs_path)
+ if exists(abs_path):
+ os.remove(abs_path)
def write_file_bin(relative_path: str, content: bytes):
abs_path = get_abs_path(relative_path)