diff --git a/skyvern/forge/sdk/db/client.py b/skyvern/forge/sdk/db/client.py index ca84b4f60..151e89f61 100644 --- a/skyvern/forge/sdk/db/client.py +++ b/skyvern/forge/sdk/db/client.py @@ -380,6 +380,7 @@ async def get_latest_step(self, task_id: str, organization_id: str | None = None .filter_by(task_id=task_id) .filter_by(organization_id=organization_id) .order_by(StepModel.order.desc()) + .order_by(StepModel.retry_index.desc()) ) ).first(): return convert_to_step(step, debug_enabled=self.debug_enabled)