From 343854c0cf971cffc975c466e79bbbc2f9fd7271 Mon Sep 17 00:00:00 2001 From: Nicholas Tindle Date: Wed, 11 Feb 2026 15:55:24 -0600 Subject: [PATCH] fix: Preserve binary file data in non-workspace executions When store_media_file returns a data URI (non-CoPilot graph executions without workspace_id), the result was silently discarded. Binary files would lose their content, keeping only a "[Binary file: N bytes]" placeholder. Now the data URI is stored in content_str on the success path too, not just in the except fallback. Co-Authored-By: Claude Opus 4.6 --- autogpt_platform/backend/backend/util/sandbox_files.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/autogpt_platform/backend/backend/util/sandbox_files.py b/autogpt_platform/backend/backend/util/sandbox_files.py index 70c255df0b..9db53ded14 100644 --- a/autogpt_platform/backend/backend/util/sandbox_files.py +++ b/autogpt_platform/backend/backend/util/sandbox_files.py @@ -231,9 +231,12 @@ async def store_sandbox_files( execution_context=execution_context, return_format="for_block_output", ) - # Result is workspace://... or data:... depending on context if result.startswith("workspace://"): workspace_ref = result + elif not file.is_text: + # Non-workspace context (graph execution): store_media_file + # returned a data URI — use it as content so binary data isn't lost. + content_str = result except Exception as e: logger.warning(f"Failed to store file {file.name} to workspace: {e}") # For binary files, fall back to data URI to prevent data loss