Skip to content

Automate browser based workflows with AI

Run 12 pytest shards and 3 Vitest shards to cut PR CI wall time (#8998)

Cindy Li84f8e361740b
diff --git a/skyvern/forge/agent.py b/skyvern/forge/agent.py
index ce83a4700..409e9abc9 100644
--- a/skyvern/forge/agent.py
+++ b/skyvern/forge/agent.py
@@ -3854,7 +3854,6 @@ class ForgeAgent:
context.task_id = task.task_id
context.navigation_goal = task.navigation_goal
context.navigation_payload = task.navigation_payload
- context.completion_gate_engine = engine
if download_baseline_files is None:
context.download_suffix_applied_files = {}
context.download_suffix = task_block.download_suffix if task_block else None
@@ -4078,9 +4077,6 @@ class ForgeAgent:
await app.ARTIFACT_MANAGER.flush_step_archive(step.step_id)
return step, detailed_output, None
- if dispatched_as_v3:
- context.completion_gate_engine = RunEngine.skyvern_v1
-
if workflow_owned_recovery:
# A recovery on the step engine would hold the block's credential placeholders with
# run-scoped credential and OTP access, so it fails instead of falling through.
@@ -4122,7 +4118,6 @@ class ForgeAgent:
)
# Later steps recurse with this engine; pinning v1 keeps them off the gate and this write.
engine = RunEngine.skyvern_v1
- context.completion_gate_engine = engine
if page := await browser_state.get_working_page():
await self.register_async_operations(organization, task, page)
diff --git a/skyvern/forge/agent_functions.py b/skyvern/forge/agent_functions.py
index 4597eaa7e..527a1def2 100644
--- a/skyvern/forge/agent_functions.py
+++ b/skyvern/forge/agent_functions.py
@@ -1208,9 +1208,6 @@ class AgentFunction:
async def is_recognized_submit_control(self, element: SkyvernElement) -> bool:
return False
- async def is_submit_control_for_completion(self, element: SkyvernElement) -> bool:
- return False
-
async def record_run_duration(
self,
run_type: str,
diff --git a/skyvern/forge/sdk/core/skyvern_context.py b/skyvern/forge/sdk/core/skyvern_context.py
index 4ba06039b..7db24d94f 100644
--- a/skyvern/forge/sdk/core/skyvern_context.py
+++ b/skyvern/forge/sdk/core/skyvern_context.py
@@ -723,8 +723,6 @@ class SkyvernContext:
seed_generated_totp_values: dict[str, set[str]] = field(default_factory=dict, repr=False)
multi_field_totp: dict[str, MultiFieldTotpAttempt] = field(default_factory=dict)
multi_field_totp_rejections: dict[str, MultiFieldTotpRejection] = field(default_factory=dict)
- submit_click_evidence: dict[str, tuple[datetime.datetime, int, int, int]] = field(default_factory=dict, repr=False)
- completion_gate_engine: RunEngine | None = None
multi_field_totp_mask_values: dict[str, set[str]] = field(default_factory=dict, repr=False)
multi_field_totp_prompt_values: dict[str, set[str]] = field(default_factory=dict, repr=False)
multi_field_totp_artifact_fingerprints: dict[str, tuple[frozenset[str], tuple[tuple[frozenset[str], int], ...]]] = (
diff --git a/skyvern/webeye/actions/handler.py b/skyvern/webeye/actions/handler.py
index 612141c36..f9eabb125 100644
--- a/skyvern/webeye/actions/handler.py
+++ b/skyvern/webeye/actions/handler.py
@@ -7463,37 +7463,6 @@ async def _apply_desired_click_state(
return None
-async def _is_submit_control_for_completion(element: SkyvernElement) -> bool:
- if skyvern_context.current() is None:
- return False
- try:
- return await app.AGENT_FUNCTION.is_submit_control_for_completion(element)
- except Exception:
- LOG.debug("Submit-control detection failed before click", element_id=element.get_id(), exc_info=True)
- return False
-
-
-def _record_submit_click_evidence(action: actions.Action, task: Task, step: Step) -> None:
- context = skyvern_context.current()
- if context is None:
- return
- action_order = action.action_order
- if action_order is None:
- action_order = len(step.output.actions_and_results or []) if step.output is not None else 0
- context.submit_click_evidence[task.task_id] = (
- datetime.now(UTC),
- step.order,
- step.retry_index,
- action_order,
- )
- LOG.info(
- "Submit-control click recorded for completion evidence",
- task_id=task.task_id,
- step_id=step.step_id,
- action_order=action_order,
- )
-
-
@traced(name="skyvern.agent.action.click")
async def handle_click_action(
action: actions.ClickAction,
@@ -7537,22 +7506,6 @@ async def handle_click_action(
if skyvern_element := await dom.safe_get_skyvern_element_by_id(element_id):
if await skyvern_element.navigate_to_a_href(page=page):
return [ActionSuccess()]
- submit_control = await _is_submit_control_for_completion(skyvern_element)
- if submit_control:
- try:
- # A dispatched coordinate click on a disabled button is not submit evidence.
- submit_control = await skyvern_element.get_locator().is_enabled()
- except Exception:
- LOG.debug(
- "Submit-control enabled-state lookup failed before coordinate click",
- element_id=skyvern_element.get_id(),
- exc_info=True,
- )
- submit_control = False
- else:
- submit_control = False
- else:
- submit_control = False
await EventStrategyFactory.move_cursor(page, action.x, action.y)
if action.repeat == 1:
@@ -7564,9 +7517,6 @@ async def handle_click_action(
else:
raise ValueError(f"Invalid repeat value: {action.repeat}")
- if submit_control:
- _record_submit_click_evidence(action, task, step)
-
return [ActionSuccess()]
action_phase.mark_action_phase(ActionPhase.RESOLVE_ELEMENT)
@@ -7688,10 +7638,7 @@ async def handle_click_action(
)
if action.download:
- submit_control = await _is_submit_control_for_completion(skyvern_element)
results = await handle_click_to_download_file_action(action, page, scraped_page, task, step)
- if results and results[-1].success and submit_control:
- _record_submit_click_evidence(action, task, step)
elif action.file_url:
upload_file_action = UploadFileAction(
@@ -7703,7 +7650,6 @@ async def handle_click_action(
preflight_derived_action(upload_file_action, page, parent=action, site="click_to_upload")
return await handle_upload_file_action(upload_file_action, page, scraped_page, task, step)
else:
- submit_control = await _is_submit_control_for_completion(skyvern_element)
incremental_scraped: IncrementalScrapePage | None = None
# Inside a file-download block, a non-download click authorized as a false-click candidate can
# still mint the file. If it does, the post-click dropdown/custom-select rescrape below is dead
@@ -7743,8 +7689,6 @@ async def handle_click_action(
incremental_scraped=incremental_scraped,
skyvern_frame=skyvern_frame,
)
- if results and results[-1].success and submit_control:
- _record_submit_click_evidence(action, task, step)
action_phase.mark_action_phase(ActionPhase.POST_CLICK)
if page.url != original_url:
return results
diff --git a/tests/unit/test_explicit_submit_sequential_click_bypass.py b/tests/unit/test_explicit_submit_sequential_click_bypass.py
index 4aa462f15..53d3fe7ae 100644
--- a/tests/unit/test_explicit_submit_sequential_click_bypass.py
+++ b/tests/unit/test_explicit_submit_sequential_click_bypass.py
@@ -18,8 +18,6 @@ import pytest
import skyvern.webeye.actions.handler as handler_module
from skyvern.forge.agent_functions import AgentFunction
-from skyvern.forge.sdk.core import skyvern_context
-from skyvern.forge.sdk.core.skyvern_context import SkyvernContext
from skyvern.forge.sdk.models import StepStatus
from skyvern.webeye.actions.actions import ActionStatus, ActionType, ClickAction
from skyvern.webeye.actions.handler import (
@@ -404,67 +402,6 @@ class TestHandleClickActionIntegration:
incremental.stop_listen_dom_increment.assert_awaited_once()
assert isinstance(results[-1], ActionSuccess)
- @pytest.mark.asyncio
- async def test_successful_submit_click_is_recorded_outside_the_bypass_path(
- self, monkeypatch: pytest.MonkeyPatch
- ) -> None:
- now = datetime.now(UTC)
- organization = make_organization(now)
- task = make_task(now, organization)
- step = make_step(now, task, step_id="step-1", status=StepStatus.running, order=2, retry_index=1, output=None)
- element = self._clickable_element(tag_name="button", type_value="button")
- chain_click_mock, sequential_mock, _ = self._wire_handler(monkeypatch, element)
- # This button is recognized for completion evidence, but not by the existing narrow
- # submit-bypass hook; the ordinary dropdown path still runs after the successful click.
- monkeypatch.setattr(
- handler_module.app.AGENT_FUNCTION,
- "is_submit_control_for_completion",
- AsyncMock(return_value=True),
- raising=False,
- )
- context = SkyvernContext()
- action = ClickAction(element_id="E1", action_order=4)
-
- with skyvern_context.scoped(context):
- await handle_click_action(action, self._page(), MagicMock(), task, step)
-
- chain_click_mock.assert_awaited_once()
- sequential_mock.assert_awaited_once()
- assert context.submit_click_evidence[task.task_id][1:] == (2, 1, 4)
-
- @pytest.mark.asyncio
- async def test_disabled_coordinate_submit_click_is_not_recorded(self, monkeypatch: pytest.MonkeyPatch) -> None:
- now = datetime.now(UTC)
- organization = make_organization(now)
- task = make_task(now, organization)
- step = make_step(now, task, step_id="step-1", status=StepStatus.running, order=2, output=None)
- element = self._clickable_element(tag_name="button", type_value="submit")
- element.navigate_to_a_href = AsyncMock(return_value=False) # type: ignore[method-assign]
- element.get_locator().is_enabled = AsyncMock(return_value=False) # type: ignore[method-assign]
- dom = MagicMock()
- dom.safe_get_skyvern_element_by_id = AsyncMock(return_value=element)
- monkeypatch.setattr(handler_module, "DomUtil", MagicMock(return_value=dom))
- monkeypatch.setattr(handler_module, "get_or_create_wait_config", AsyncMock(return_value=MagicMock()))
- monkeypatch.setattr(handler_module.EventStrategyFactory, "move_cursor", AsyncMock())
- monkeypatch.setattr(
- handler_module.app.AGENT_FUNCTION,
- "is_submit_control_for_completion",
- AsyncMock(return_value=True),
- raising=False,
- )
- page = self._page()
- page.evaluate = AsyncMock(return_value="E1")
- page.mouse.click = AsyncMock()
- context = SkyvernContext()
-
- with skyvern_context.scoped(context):
- result = await handle_click_action(ClickAction(element_id="E1", x=10, y=10), page, MagicMock(), task, step)
-
- assert isinstance(result[-1], ActionSuccess)
- page.mouse.click.assert_awaited_once()
- element.get_locator().is_enabled.assert_awaited_once()
- assert task.task_id not in context.submit_click_evidence
-
class _FakePage:
"""Minimal Playwright-page stand-in that records event listeners and can emit