diff --git a/agents/runner.py b/agents/runner.py index 763be3e..f099a6f 100644 --- a/agents/runner.py +++ b/agents/runner.py @@ -1162,7 +1162,7 @@ def _execute_department_head_step( }, } - return { + ret = { "success": sub_result.get("success", False), "output": json.dumps(summary, ensure_ascii=False), "cost_usd": sub_result.get("total_cost_usd", 0), @@ -1170,6 +1170,10 @@ def _execute_department_head_step( "duration_seconds": sub_result.get("total_duration_seconds", 0), "last_sub_role": last_sub_role, } + if not sub_result.get("success"): + ret["blocked_reason"] = sub_result.get("blocked_reason") or sub_result.get("error") + ret["error"] = sub_result.get("error") + return ret # --------------------------------------------------------------------------- @@ -1585,8 +1589,9 @@ def run_pipeline( total_tokens=total_tokens, total_duration_seconds=total_duration, ) - error_msg = f"Department {role} sub-pipeline failed" - models.update_task(conn, task_id, status="blocked", blocked_reason=error_msg) + blocked_reason = dept_result.get("blocked_reason") or dept_result.get("error") or f"Department {role} sub-pipeline failed" + error_msg = f"Department {role} sub-pipeline failed: {dept_result.get('output', '')[:200]}" + models.update_task(conn, task_id, status="blocked", blocked_reason=blocked_reason) return { "success": False, "error": error_msg,