Better handling of failed to summarize failure reason (#1218)

This commit is contained in:
Shuchang Zheng
2024-11-19 00:04:22 -08:00
committed by GitHub
parent 2c81875baf
commit 5477612d37

View File

@@ -1700,11 +1700,11 @@ class ForgeAgent:
step: Step,
page: Page | None,
) -> str:
steps_results = []
try:
steps = await app.DATABASE.get_task_steps(
task_id=task.task_id, organization_id=organization.organization_id
)
steps_results = []
for step_cnt, step in enumerate(steps):
if step.output is None:
continue
@@ -1741,9 +1741,11 @@ class ForgeAgent:
)
json_response = await app.LLM_API_HANDLER(prompt=prompt, screenshots=screenshots, step=step)
return json_response.get("reasoning", "")
except Exception:
LOG.exception("Failed to summary the failure reason", task=task.task_id)
LOG.warning("Failed to summary the failure reason", task_id=task.task_id, step_id=step.step_id)
if steps_results:
last_step_result = steps_results[-1]
return f"Step {last_step_result['order']}: {last_step_result['actions_result']}"
return ""
async def handle_completed_step(