Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat: default /v1/run/tasks engine to v1 (SKY-8566) (#5403)
Suchintanb727a22c45f4
diff --git a/skyvern/library/skyvern.py b/skyvern/library/skyvern.pyindex 50fc89c23..09909ab5e 100644--- a/skyvern/library/skyvern.py+++ b/skyvern/library/skyvern.py@@ -275,7 +275,7 @@ class Skyvern(AsyncSkyvern):async def run_task(self,prompt: str,- engine: RunEngine = RunEngine.skyvern_v2,+ engine: RunEngine = RunEngine.skyvern_v1,model: dict[str, Any] | None = None,url: str | None = None,webhook_url: str | None = None,diff --git a/skyvern/library/skyvern_browser_page_agent.py b/skyvern/library/skyvern_browser_page_agent.pyindex 154c5f2b0..6cb201916 100644--- a/skyvern/library/skyvern_browser_page_agent.py+++ b/skyvern/library/skyvern_browser_page_agent.py@@ -36,7 +36,7 @@ class SkyvernBrowserPageAgent:async def run_task(self,prompt: str,- engine: RunEngine = RunEngine.skyvern_v2,+ engine: RunEngine = RunEngine.skyvern_v1,model: dict[str, Any] | None = None,url: str | None = None,webhook_url: str | None = None,@@ -53,7 +53,7 @@ class SkyvernBrowserPageAgent:Args:prompt: Natural language description of the task to perform.- engine: The execution engine to use. Defaults to skyvern_v2.+ engine: The execution engine to use. Defaults to skyvern_v1.model: LLM model configuration options.url: URL to navigate to. If not provided, uses the current page URL.webhook_url: URL to receive webhook notifications about task progress.diff --git a/skyvern/schemas/docs/doc_strings.py b/skyvern/schemas/docs/doc_strings.pyindex 51ad0e5b2..6fb8e1dfc 100644--- a/skyvern/schemas/docs/doc_strings.py+++ b/skyvern/schemas/docs/doc_strings.py@@ -7,7 +7,7 @@ The starting URL for the task. If not provided, Skyvern will attempt to determin"""TASK_ENGINE_DOC_STRING = """-The engine that powers the agent task. The default value is `skyvern-2.0`, the latest Skyvern agent that performs pretty well with complex and multi-step tasks. `skyvern-1.0` is good for simple tasks like filling a form, or searching for information on Google. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool.+The engine that powers the agent task. The default value is `skyvern-1.0`, which is good for simple tasks like filling a form, or searching for information on Google. `skyvern-2.0` is the latest Skyvern agent that performs well with complex and multi-step tasks. The `openai-cua` engine uses OpenAI's CUA model. The `anthropic-cua` uses Anthropic's Claude Sonnet 3.7 model with the computer use tool."""PROXY_LOCATION_DOC_STRING = """diff --git a/skyvern/schemas/runs.py b/skyvern/schemas/runs.pyindex 649091888..ba4339b89 100644--- a/skyvern/schemas/runs.py+++ b/skyvern/schemas/runs.py@@ -5,7 +5,7 @@ from enum import StrEnumfrom typing import Annotated, Any, Literal, Unionfrom zoneinfo import ZoneInfo-from pydantic import BaseModel, ConfigDict, Field, field_validator+from pydantic import BaseModel, ConfigDict, Field, field_validator, model_validatorfrom skyvern.forge.sdk.schemas.files import FileInfofrom skyvern.forge.sdk.workflow.models.validators import normalize_run_with@@ -382,7 +382,7 @@ class TaskRunRequest(BaseModel):examples=TASK_URL_EXAMPLES,)engine: RunEngine = Field(- default=RunEngine.skyvern_v2,+ default=RunEngine.skyvern_v1,description=TASK_ENGINE_DOC_STRING,)title: str | None = Field(@@ -482,6 +482,12 @@ class TaskRunRequest(BaseModel):return validate_url(url)+ @model_validator(mode="after")+ def _force_v2_for_publish_workflow(self) -> TaskRunRequest:+ if self.publish_workflow and self.engine != RunEngine.skyvern_v2:+ self.engine = RunEngine.skyvern_v2+ return self+class WorkflowRunRequest(BaseModel):workflow_id: str = Field(diff --git a/tests/unit/test_default_task_version.py b/tests/unit/test_default_task_version.pyindex ff43838e9..edbdb6747 100644--- a/tests/unit/test_default_task_version.py+++ b/tests/unit/test_default_task_version.py@@ -73,3 +73,34 @@ class TestServiceDefault:sig = inspect.signature(WorkflowService.create_workflow_from_prompt)assert sig.parameters["task_version"].default == "v1"+++class TestTaskRunRequestEngine:+ def test_default_engine_is_v1(self) -> None:+ """TaskRunRequest.engine must default to skyvern_v1 (skyvern-1.0)."""+ from skyvern.schemas.runs import RunEngine, TaskRunRequest++ req = TaskRunRequest(prompt="hello")+ assert req.engine == RunEngine.skyvern_v1++ def test_explicit_v2_engine_preserved(self) -> None:+ """Explicitly passing skyvern_v2 should be preserved."""+ from skyvern.schemas.runs import RunEngine, TaskRunRequest++ req = TaskRunRequest(prompt="hello", engine=RunEngine.skyvern_v2)+ assert req.engine == RunEngine.skyvern_v2++ def test_publish_workflow_forces_v2(self) -> None:+ """publish_workflow=True must force engine to v2, since v1 doesn't support it."""+ from skyvern.schemas.runs import RunEngine, TaskRunRequest++ req = TaskRunRequest(prompt="hello", publish_workflow=True)+ assert req.engine == RunEngine.skyvern_v2++ def test_publish_workflow_false_keeps_v1(self) -> None:+ """publish_workflow=False (default) should keep the v1 default."""+ from skyvern.schemas.runs import RunEngine, TaskRunRequest++ req = TaskRunRequest(prompt="hello")+ assert req.engine == RunEngine.skyvern_v1+ assert req.publish_workflow is False