add workflow failure reason (#1198)

This commit is contained in:
LawyZheng
2024-11-15 11:07:44 +08:00
committed by GitHub
parent b2516dc95f
commit e3aa583b24
7 changed files with 152 additions and 25 deletions

View File

@@ -1083,13 +1083,16 @@ class AgentDB:
LOG.error("SQLAlchemyError", exc_info=True)
raise
async def update_workflow_run(self, workflow_run_id: str, status: WorkflowRunStatus) -> WorkflowRun | None:
async def update_workflow_run(
self, workflow_run_id: str, status: WorkflowRunStatus, failure_reason: str | None = None
) -> WorkflowRun | None:
async with self.Session() as session:
workflow_run = (
await session.scalars(select(WorkflowRunModel).filter_by(workflow_run_id=workflow_run_id))
).first()
if workflow_run:
workflow_run.status = status
workflow_run.failure_reason = failure_reason
await session.commit()
await session.refresh(workflow_run)
return convert_to_workflow_run(workflow_run)