add step prepare and browser clean up (#554)

This commit is contained in:
LawyZheng
2024-07-05 02:17:34 +08:00
committed by GitHub
parent 7cdd986bde
commit be97d0bdb1
4 changed files with 40 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ from skyvern.forge import app
from skyvern.forge.async_operations import AsyncOperation
from skyvern.forge.sdk.models import Organization, Step, StepStatus
from skyvern.forge.sdk.schemas.tasks import Task, TaskStatus
from skyvern.webeye.browser_factory import BrowserState
class AgentFunction:
@@ -14,7 +15,7 @@ class AgentFunction:
step: Step,
) -> None:
"""
Checks if the step can be executed.
Checks if the step can be executed. It is called before the step is executed.
:return: A tuple of whether the step can be executed and a list of reasons why it can't be executed.
"""
reasons = []
@@ -36,6 +37,18 @@ class AgentFunction:
if not can_execute:
raise StepUnableToExecuteError(step_id=step.step_id, reason=f"Cannot execute step. Reasons: {reasons}")
async def prepare_step_execution(
self,
organization: Organization | None,
task: Task,
step: Step,
browser_state: BrowserState,
) -> None:
"""
Get prepared for the step execution. It's called at the first beginning when step running.
"""
return
def generate_async_operations(
self,
organization: Organization,