diff --git a/autogpts/autogpt/autogpt/app/agent_protocol_server.py b/autogpts/autogpt/autogpt/app/agent_protocol_server.py index 4bfc1940..08b2f212 100644 --- a/autogpts/autogpt/autogpt/app/agent_protocol_server.py +++ b/autogpts/autogpt/autogpt/app/agent_protocol_server.py @@ -334,7 +334,7 @@ class AgentProtocolServer: else: file_path = artifact.relative_path workspace = get_task_agent_file_workspace(task_id, self.agent_manager) - retrieved_artifact = workspace.read_file(file_path) + retrieved_artifact = workspace.read_file(file_path, binary=True) except NotFoundError as e: raise except FileNotFoundError as e: diff --git a/autogpts/autogpt/autogpt/file_workspace/file_workspace.py b/autogpts/autogpt/autogpt/file_workspace/file_workspace.py index 7fe918b6..37da359e 100644 --- a/autogpts/autogpt/autogpt/file_workspace/file_workspace.py +++ b/autogpts/autogpt/autogpt/file_workspace/file_workspace.py @@ -60,9 +60,9 @@ class FileWorkspace: full_path = self.get_path(path) return open(full_path, mode) - def read_file(self, path: str | Path): + def read_file(self, path: str | Path, binary: bool = False): """Read a file in the workspace.""" - with self.open_file(path, "r") as file: + with self.open_file(path, "rb" if binary else "r") as file: return file.read() def write_file(self, path: str | Path, content: str | bytes):