diff --git a/pilot/helpers/AgentConvo.py b/pilot/helpers/AgentConvo.py index 68f11df71..d662eeef2 100644 --- a/pilot/helpers/AgentConvo.py +++ b/pilot/helpers/AgentConvo.py @@ -168,6 +168,9 @@ def replace_files(self): def replace_file_content(self, message, file_path, new_content): escaped_file_path = re.escape(file_path) + # Escape any \U in the file path + escaped_file_path = escaped_file_path.replace("\\U", "\\\\U") + pattern = rf'\*\*{{ {escaped_file_path} }}\*\*\n```\n(.*?)\n```' new_section_content = f'**{{ {file_path} }}**\n```\n{new_content}\n```'