diff --git a/app/services/run_service.py b/app/services/run_service.py index 8a20c4c..d1aa838 100644 --- a/app/services/run_service.py +++ b/app/services/run_service.py @@ -180,10 +180,19 @@ class RunService: # If task completed, get result if result.ready(): if result.successful(): - run_data["status"] = "completed" task_result = result.result if isinstance(task_result, dict): - run_data["output_cid"] = task_result.get("output_cid") + # Check task's own success flag and output_cid + task_success = task_result.get("success", True) + output_cid = task_result.get("output_cid") + if task_success and output_cid: + run_data["status"] = "completed" + run_data["output_cid"] = output_cid + else: + run_data["status"] = "failed" + run_data["error"] = task_result.get("error", "No output produced") + else: + run_data["status"] = "completed" else: run_data["status"] = "failed" run_data["error"] = str(result.result) @@ -267,10 +276,19 @@ class RunService: # If task completed, get result if result.ready(): if result.successful(): - run_data["status"] = "completed" task_result = result.result if isinstance(task_result, dict): - run_data["output_cid"] = task_result.get("output_cid") + # Check task's own success flag and output_cid + task_success = task_result.get("success", True) + output_cid = task_result.get("output_cid") + if task_success and output_cid: + run_data["status"] = "completed" + run_data["output_cid"] = output_cid + else: + run_data["status"] = "failed" + run_data["error"] = task_result.get("error", "No output produced") + else: + run_data["status"] = "completed" else: run_data["status"] = "failed" run_data["error"] = str(result.result)