Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
support passing run_with for run_task endpoint (mostly for task v2) (#4576)
Shuchang Zheng69e1ea15cc9a
diff --git a/skyvern/forge/sdk/routes/agent_protocol.py b/skyvern/forge/sdk/routes/agent_protocol.pyindex 8760dc8f0..abc57184e 100644--- a/skyvern/forge/sdk/routes/agent_protocol.py+++ b/skyvern/forge/sdk/routes/agent_protocol.py@@ -264,6 +264,7 @@ async def run_task(extra_http_headers=run_request.extra_http_headers,browser_session_id=run_request.browser_session_id,browser_address=run_request.browser_address,+ run_with=run_request.run_with,)except MissingBrowserAddressError as e:raise HTTPException(status_code=400, detail=str(e)) from ediff --git a/skyvern/schemas/runs.py b/skyvern/schemas/runs.pyindex 86f39d135..dca180940 100644--- a/skyvern/schemas/runs.py+++ b/skyvern/schemas/runs.py@@ -437,6 +437,11 @@ class TaskRunRequest(BaseModel):description="The CDP address for the task.",examples=["http://127.0.0.1:9222", "ws://127.0.0.1:9222/devtools/browser/1234567890"],)+ run_with: str | None = Field(+ default=None,+ description="Whether to run the task with agent or code.",+ examples=["agent", "code"],+ )@field_validator("url", "webhook_url", "totp_url")@classmethoddiff --git a/skyvern/services/task_v2_service.py b/skyvern/services/task_v2_service.pyindex 4759d3418..f7cf226bc 100644--- a/skyvern/services/task_v2_service.py+++ b/skyvern/services/task_v2_service.py@@ -209,6 +209,7 @@ async def initialize_task_v2(browser_session_id=browser_session_id,extra_http_headers=extra_http_headers,browser_address=browser_address,+ run_with=run_with,),workflow_permanent_id=new_workflow.workflow_permanent_id,organization=organization,@@ -755,10 +756,11 @@ async def run_task_v2_helper(context=context,screenshots=scraped_page.screenshots,)- await app.WORKFLOW_SERVICE.generate_script_if_needed(- workflow=workflow,- workflow_run=workflow_run,- )+ if task_v2.run_with == "code":+ await app.WORKFLOW_SERVICE.generate_script_if_needed(+ workflow=workflow,+ workflow_run=workflow_run,+ )breakif not plan: