From 05e4c5d901a4b1eae6f353ff485d9573cc5d26fc Mon Sep 17 00:00:00 2001 From: sharath <29162020+tnfssc@users.noreply.github.com> Date: Sun, 1 Jun 2025 10:15:20 +0000 Subject: [PATCH] fix(agent): handle image context content parsing more robustly --- backend/agent/run.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/agent/run.py b/backend/agent/run.py index 791ae55c..05e21ef7 100644 --- a/backend/agent/run.py +++ b/backend/agent/run.py @@ -180,7 +180,7 @@ async def run_agent( latest_image_context_msg = await client.table('messages').select('*').eq('thread_id', thread_id).eq('type', 'image_context').order('created_at', desc=True).limit(1).execute() if latest_image_context_msg.data and len(latest_image_context_msg.data) > 0: try: - image_context_content = json.loads(latest_image_context_msg.data[0]["content"]) + image_context_content = latest_image_context_msg.data[0]["content"] if isinstance(latest_image_context_msg.data[0]["content"], dict) else json.loads(latest_image_context_msg.data[0]["content"]) base64_image = image_context_content.get("base64") mime_type = image_context_content.get("mime_type") file_path = image_context_content.get("file_path", "unknown file")