mirror of
https://github.com/Skyvern-AI/skyvern.git
synced 2025-09-12 16:29:42 +00:00
the error raised from the base validate_step_execution shouldn't be handled to fail the task (#422)
This commit is contained in:
parent
3f3fbbc63d
commit
fbe42994a9
3 changed files with 17 additions and 4 deletions
|
@ -266,7 +266,12 @@ class UnknownElementTreeFormat(SkyvernException):
|
||||||
|
|
||||||
class StepTerminationError(SkyvernException):
|
class StepTerminationError(SkyvernException):
|
||||||
def __init__(self, step_id: str, reason: str) -> None:
|
def __init__(self, step_id: str, reason: str) -> None:
|
||||||
super().__init__(f"Step {step_id} cannot be executed and task is terminated. Reason: {reason}")
|
super().__init__(f"Step {step_id} cannot be executed and task is failed. Reason: {reason}")
|
||||||
|
|
||||||
|
|
||||||
|
class StepUnableToExecuteError(SkyvernException):
|
||||||
|
def __init__(self, step_id: str, reason: str) -> None:
|
||||||
|
super().__init__(f"Step {step_id} cannot be executed and task execution is stopped. Reason: {reason}")
|
||||||
|
|
||||||
|
|
||||||
class UnsupportedActionType(SkyvernException):
|
class UnsupportedActionType(SkyvernException):
|
||||||
|
|
|
@ -18,6 +18,7 @@ from skyvern.exceptions import (
|
||||||
InvalidWorkflowTaskURLState,
|
InvalidWorkflowTaskURLState,
|
||||||
MissingBrowserStatePage,
|
MissingBrowserStatePage,
|
||||||
StepTerminationError,
|
StepTerminationError,
|
||||||
|
StepUnableToExecuteError,
|
||||||
TaskNotFound,
|
TaskNotFound,
|
||||||
)
|
)
|
||||||
from skyvern.forge import app
|
from skyvern.forge import app
|
||||||
|
@ -328,9 +329,16 @@ class ForgeAgent:
|
||||||
|
|
||||||
return step, detailed_output, next_step
|
return step, detailed_output, next_step
|
||||||
# TODO (kerem): Let's add other exceptions that we know about here as custom exceptions as well
|
# TODO (kerem): Let's add other exceptions that we know about here as custom exceptions as well
|
||||||
|
except StepUnableToExecuteError:
|
||||||
|
LOG.error(
|
||||||
|
"Step cannot be executed. Task execution stopped",
|
||||||
|
task_id=task.task_id,
|
||||||
|
step_id=step.step_id,
|
||||||
|
)
|
||||||
|
raise
|
||||||
except StepTerminationError as e:
|
except StepTerminationError as e:
|
||||||
LOG.error(
|
LOG.error(
|
||||||
"Step cannot be executed. Task terminated",
|
"Step cannot be executed. Task failed.",
|
||||||
task_id=task.task_id,
|
task_id=task.task_id,
|
||||||
step_id=step.step_id,
|
step_id=step.step_id,
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from playwright.async_api import Page
|
from playwright.async_api import Page
|
||||||
|
|
||||||
from skyvern.exceptions import StepTerminationError
|
from skyvern.exceptions import StepUnableToExecuteError
|
||||||
from skyvern.forge import app
|
from skyvern.forge import app
|
||||||
from skyvern.forge.async_operations import AsyncOperation
|
from skyvern.forge.async_operations import AsyncOperation
|
||||||
from skyvern.forge.sdk.models import Organization, Step, StepStatus
|
from skyvern.forge.sdk.models import Organization, Step, StepStatus
|
||||||
|
@ -34,7 +34,7 @@ class AgentFunction:
|
||||||
|
|
||||||
can_execute = has_valid_task_status and has_valid_step_status and has_no_running_steps
|
can_execute = has_valid_task_status and has_valid_step_status and has_no_running_steps
|
||||||
if not can_execute:
|
if not can_execute:
|
||||||
raise StepTerminationError(step_id=step.step_id, reason="Cannot execute step. Reasons: {reasons}")
|
raise StepUnableToExecuteError(step_id=step.step_id, reason=f"Cannot execute step. Reasons: {reasons}")
|
||||||
|
|
||||||
def generate_async_operations(
|
def generate_async_operations(
|
||||||
self,
|
self,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue