Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix(SKY-12398): verify text-input commit with fallback ladder and repeated-action circuit breaker (#7531)
Aaron Perezf6dff064c2f1
diff --git a/skyvern/exceptions.py b/skyvern/exceptions.pyindex b88e2cb8b..8613ac02c 100644--- a/skyvern/exceptions.py+++ b/skyvern/exceptions.py@@ -219,6 +219,26 @@ class MaskedInputReadbackMismatch(SkyvernException):)+class InputTextCommitMismatch(SkyvernException):+ def __init__(self, *, expected_length: int, actual_length: int):+ self.expected_length = expected_length+ self.actual_length = actual_length+ super().__init__(+ f"Input text commit mismatch: expected length {expected_length}, found actual length {actual_length}."+ )+++class RepeatedActionFailure(SkyvernException):+ def __init__(self, *, element_id: str, attempt_count: int, failure_description: str):+ self.element_id = element_id+ self.attempt_count = attempt_count+ self.failure_description = failure_description+ super().__init__(+ f"Action on element {element_id} failed identically {attempt_count} consecutive times: "+ f"{failure_description}."+ )++class ConditionalBranchEvaluationError(SkyvernException):"""A conditional block could not resolve which branch to take."""diff --git a/skyvern/forge/agent.py b/skyvern/forge/agent.pyindex 8520f2683..60fc1dd7e 100644--- a/skyvern/forge/agent.py+++ b/skyvern/forge/agent.py@@ -57,6 +57,7 @@ from skyvern.exceptions import (MissingExtractActionsResponse,NoTOTPVerificationCodeFound,PDFEmbedBase64DecodeError,+ RepeatedActionFailure,ScrapingFailed,SkyvernException,StepTerminationError,@@ -168,7 +169,7 @@ from skyvern.webeye.actions.parse_actions import (parse_cua_actions,parse_ui_tars_actions,)-from skyvern.webeye.actions.responses import ActionResult, ActionSuccess+from skyvern.webeye.actions.responses import ActionFailure, ActionResult, ActionSuccessfrom skyvern.webeye.browser_state import BrowserStatefrom skyvern.webeye.cdp_download_interceptor import download_filename_from_suffixfrom skyvern.webeye.scraper.scraped_page import ElementTreeFormat, ScrapedPage@@ -180,6 +181,103 @@ RECOVERABLE_BLANK_WORKFLOW_TASK_URLS = {":"}EXTRACT_ACTION_TEMPLATE = "extract-action"DECISIVE_CRITERION_VALIDATE_TEMPLATE = "decisive-criterion-validate"+REPEATED_ACTION_FAILURE_LIMIT = 3+REPEATED_ACTION_CIRCUIT_BREAKER_FLAG = "REPEATED_ACTION_CIRCUIT_BREAKER"+_ACTION_REPEAT_PAYLOAD_FIELDS = (+ "button",+ "download",+ "duration",+ "file_name",+ "file_url",+ "hold",+ "hold_seconds",+ "is_checked",+ "is_magic_link",+ "keys",+ "option",+ "path",+ "repeat",+ "start_x",+ "start_y",+ "text",+ "url",+ "verification_code",+ "x",+ "y",+)+_PERSISTED_ACTION_REPEAT_PAYLOAD_FIELDS = tuple(+ field for field in _ACTION_REPEAT_PAYLOAD_FIELDS if field in Action.model_fields+)+++def _repeated_action_identity(action: Action) -> tuple[ActionType, str, str] | None:+ if not action.action_type.is_web_action() or not action.element_id:+ return None+ payload = {field: getattr(action, field) for field in _PERSISTED_ACTION_REPEAT_PAYLOAD_FIELDS}+ payload_digest = hashlib.sha256(+ json.dumps(payload, default=str, sort_keys=True, separators=(",", ":")).encode()+ ).hexdigest()+ return action.action_type, action.element_id, payload_digest+++def _get_repeated_action_failure(+ attempts: list[tuple[Action, list[ActionResult]]],+) -> RepeatedActionFailure | None:+ recent_attempts = attempts[-REPEATED_ACTION_FAILURE_LIMIT:]+ if len(recent_attempts) < REPEATED_ACTION_FAILURE_LIMIT:+ return None+ identities = [_repeated_action_identity(action) for action, _ in recent_attempts]+ if identities[0] is None or any(identity != identities[0] for identity in identities[1:]):+ return None+ if any(not results or any(result.success for result in results) for _, results in recent_attempts):+ return None+ _, element_id, _ = identities[0]+ final_result = recent_attempts[-1][1][-1]+ failure_description = final_result.exception_type or "UnknownFailure"+ return RepeatedActionFailure(+ element_id=element_id,+ attempt_count=REPEATED_ACTION_FAILURE_LIMIT,+ failure_description=failure_description,+ )+++async def _is_repeated_action_breaker_enabled(task: Task) -> bool:+ try:+ distinct_id = task.workflow_run_id if task.workflow_run_id else task.task_id+ return bool(+ await app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached(+ REPEATED_ACTION_CIRCUIT_BREAKER_FLAG,+ distinct_id,+ properties={"organization_id": task.organization_id},+ )+ )+ except Exception:+ LOG.warning(+ "Failed to evaluate repeated-action circuit breaker flag; defaulting to disabled",+ task_id=task.task_id,+ exc_info=True,+ )+ return False+++async def _get_previous_action_attempts(task: Task, current_step_id: str) -> list[tuple[Action, list[ActionResult]]]:+ try:+ steps = await app.DATABASE.tasks.get_task_steps(+ task_id=task.task_id,+ organization_id=task.organization_id,+ )+ except Exception:+ LOG.warning("Failed to load action history for repeated-action detection", task_id=task.task_id, exc_info=True)+ return []+ if not isinstance(steps, list):+ return []+ attempts: list[tuple[Action, list[ActionResult]]] = []+ for previous_step in sorted(steps, key=lambda item: (item.order, item.retry_index)):+ if previous_step.step_id == current_step_id:+ continue+ if previous_step.output and previous_step.output.actions_and_results:+ attempts.extend(previous_step.output.actions_and_results)+ return attemptsasync def resolve_inherited_workflow_task_page(browser_state: BrowserState, workflow_run_id: str) -> Page:@@ -1777,6 +1875,7 @@ class ForgeAgent:element_id_to_action_index[action.element_id] = action_idxelement_id_to_last_action: dict[str, int] = dict()+ previous_step_attempts: list[tuple[Action, list[ActionResult]]] | None = Nonetry:wait_config = await get_or_create_wait_config(task.task_id, task.workflow_run_id, task.organization_id)base_delay = get_wait_time(wait_config, "inter_action_delay", default=0.5)@@ -1891,6 +1990,42 @@ class ForgeAgent:action,results,)+ if (+ results+ and not any(result.success for result in results)+ and await _is_repeated_action_breaker_enabled(task)+ ):+ current_step_attempts = detailed_agent_step_output.actions_and_results[: action_idx + 1]+ repeated_failure = _get_repeated_action_failure(current_step_attempts)+ current_identity = _repeated_action_identity(action)+ current_attempts_can_follow_history = current_identity is not None and all(+ _repeated_action_identity(attempt_action) == current_identity+ and attempt_results+ and not any(result.success for result in attempt_results)+ for attempt_action, attempt_results in current_step_attempts+ )+ if (+ repeated_failure is None+ and len(current_step_attempts) < REPEATED_ACTION_FAILURE_LIMIT+ and current_attempts_can_follow_history+ ):+ if previous_step_attempts is None:+ previous_step_attempts = await _get_previous_action_attempts(task, step.step_id)+ repeated_failure = _get_repeated_action_failure(previous_step_attempts + current_step_attempts)+ if repeated_failure is not None:+ final_result = results[-1]+ repeated_result = ActionFailure(+ repeated_failure,+ stop_execution_on_failure=final_result.stop_execution_on_failure,+ download_triggered=final_result.download_triggered,+ interacted_with_sibling=bool(final_result.interacted_with_sibling),+ interacted_with_parent=bool(final_result.interacted_with_parent),+ )+ repeated_result.skip_remaining_actions = final_result.skip_remaining_actions+ repeated_result.needs_followup = final_result.needs_followup+ repeated_result.followup_message = final_result.followup_message+ results = [repeated_result]+ detailed_agent_step_output.actions_and_results[action_idx] = (action, results)# Determine wait time between actionswait_time = random.uniform(base_delay, base_delay * 2) if base_delay > 0 else 0.0diff --git a/skyvern/webeye/actions/handler.py b/skyvern/webeye/actions/handler.pyindex 5d9b711a8..1098d5295 100644--- a/skyvern/webeye/actions/handler.py+++ b/skyvern/webeye/actions/handler.py@@ -48,6 +48,7 @@ from skyvern.exceptions import (IllegitComplete,ImaginaryFileUrl,ImaginarySecretValue,+ InputTextCommitMismatch,InputToInvisibleElement,InputToReadonlyElement,InteractWithDisabledElement,@@ -177,6 +178,7 @@ FIX_TEL_INPUT_DIGIT_DROP_FLAG = "FIX_TEL_INPUT_DIGIT_DROP"VERIFY_EMERGING_SELECT_PICK_FLAG = "VERIFY_EMERGING_SELECT_PICK"FIX_MASKED_INPUT_READBACK_FLAG = "FIX_MASKED_INPUT_READBACK"SURFACE_BLOCKED_FORM_ADVANCE_FLAG = "SURFACE_BLOCKED_FORM_ADVANCE"+VERIFY_INPUT_TEXT_COMMIT_FLAG = "VERIFY_INPUT_TEXT_COMMIT"COLLAPSE_SELECT_FANOUT_FLAG = "COLLAPSE_SELECT_FANOUT"COLLAPSE_CUSTOM_SELECT_FANOUT_FLAG = "COLLAPSE_CUSTOM_SELECT_FANOUT"COLLAPSE_AUTOCOMPLETE_FANOUT_FLAG = "COLLAPSE_AUTOCOMPLETE_FANOUT"@@ -1423,6 +1425,10 @@ async def _is_autocomplete_commit_required_enabled(task: Task) -> bool:return await _is_org_flag_enabled(task, AUTOCOMPLETE_COMMIT_REQUIRED_FLAG, "autocomplete-commit-required")+async def _is_input_text_commit_verification_enabled(task: Task) -> bool:+ return await _is_org_flag_enabled(task, VERIFY_INPUT_TEXT_COMMIT_FLAG, "input-text-commit")++async def _resolve_collapse_xp_assignment(experimentation_provider: BaseExperimentationProvider,task: Task,@@ -1609,6 +1615,274 @@ async def _fill_nanp_tel_with_readback(return None+_INPUT_TEXT_MASK_FORMAT_RE = re.compile(r"[\s\-_().]")+_NON_TEXT_INPUT_TYPES = {+ "button",+ "checkbox",+ "color",+ "date",+ "datetime-local",+ "file",+ "hidden",+ "image",+ "month",+ "password",+ "radio",+ "range",+ "reset",+ "submit",+ "tel",+ "time",+ "week",+}+_INPUT_COMMIT_NAVIGATION_ERRORS = (+ "execution context was destroyed",+ "navigation",+ "target closed",+)+_INPUT_COMMIT_DETACHED_ERRORS = ("detached", "not attached")+_MASK_NORMALIZED_INPUT_TYPES = {"search", "text", "textarea"}+_SET_NATIVE_INPUT_VALUE_JS = """+(element, value) => {+ const prototype = element instanceof HTMLTextAreaElement+ ? HTMLTextAreaElement.prototype+ : HTMLInputElement.prototype;+ const setter = Object.getOwnPropertyDescriptor(prototype, "value").set;+ setter.call(element, value);+ element.dispatchEvent(new Event("input", { bubbles: true }));+ element.dispatchEvent(new Event("change", { bubbles: true }));+ element.blur();+}+"""+++def _normalize_input_text_value(value: str | None) -> str:+ return _INPUT_TEXT_MASK_FORMAT_RE.sub("", value or "")+++def input_text_values_match(expected_value: str, actual_value: str | None, *, input_type: str) -> bool:+ """Decide whether a field committed what was typed.++ A field has committed when its value derives from the typed text. That covers an exact match, a+ reformat that only rearranges separators ("1234567890" -> "(123) 456-7890"), and an enrichment+ that extends the typed value ("12345" -> "12345-6789"). Only three things are failures: an empty+ field, a field still showing unfilled mask placeholders, and a genuinely different value.++ Deriving is read as a prefix rather than a substring: extending what was typed is a commit, but a+ value that merely happens to contain it is not.+ """+ expected_trimmed = expected_value.strip()+ actual_trimmed = (actual_value or "").strip()+ if not expected_trimmed:+ return True+ if not actual_trimmed:+ return False+ if expected_trimmed == actual_trimmed:+ return True+ if input_type not in _MASK_NORMALIZED_INPUT_TYPES:+ return False+ expected_normalized = _normalize_input_text_value(expected_trimmed).casefold()+ actual_normalized = _normalize_input_text_value(actual_trimmed).casefold()+ if not expected_normalized:+ # Nothing but separators was typed, so only separators may come back - anything else is a+ # different value, not a reformat of this one.+ return not actual_normalized+ # An all-placeholder commit ("_____") normalizes away to nothing: the mask took the keystrokes+ # and kept none of them.+ if not actual_normalized:+ return False+ return actual_normalized.startswith(expected_normalized)+++def _is_input_commit_navigation_error(exc: PlaywrightError) -> bool:+ return any(message in str(exc).lower() for message in _INPUT_COMMIT_NAVIGATION_ERRORS)+++def _is_input_commit_detached_error(exc: PlaywrightError) -> bool:+ return any(message in str(exc).lower() for message in _INPUT_COMMIT_DETACHED_ERRORS)+++def _is_plausible_autocomplete_rewrite(expected_value: str, actual_value: str | None) -> bool:+ # A suggestion rewrite contains or extends the typed text; the reverse containment+ # (actual is a prefix/fragment of expected) is a dropped-input failure, not a rewrite.+ expected_trimmed = expected_value.strip().casefold()+ actual_trimmed = (actual_value or "").strip().casefold()+ return bool(expected_trimmed and actual_trimmed) and expected_trimmed in actual_trimmed+++_OPTION_UI_ROLES = {"listbox", "option"}+++def _incremental_elements_contain_option_ui(elements: list[dict]) -> bool:+ stack: list[dict] = [element for element in elements if isinstance(element, dict)]+ while stack:+ element = stack.pop()+ if str(element.get("tagName") or "").lower() == "li":+ return True+ attributes = element.get("attributes")+ if isinstance(attributes, dict) and str(attributes.get("role") or "").lower() in _OPTION_UI_ROLES:+ return True+ children = element.get("children")+ if isinstance(children, list):+ stack.extend(child for child in children if isinstance(child, dict))+ return False+++async def _read_generic_input_commit(+ *,+ skyvern_element: SkyvernElement,+ dom: DomUtil,+ tag_name: str,+ input_type: str,+ expected_value: str,+ allow_autocomplete_rewrite: bool,+ allow_reresolve: bool,+) -> tuple[bool, str | None, SkyvernElement]:+ try:+ actual_value = await get_input_value(tag_name=tag_name, locator=skyvern_element.get_locator())+ except PlaywrightError as exc:+ if _is_input_commit_navigation_error(exc):+ return True, None, skyvern_element+ if not allow_reresolve or not _is_input_commit_detached_error(exc):+ raise+ skyvern_element = await dom.get_skyvern_element_by_id(skyvern_element.get_id())+ actual_value = await get_input_value(tag_name=tag_name, locator=skyvern_element.get_locator())+ committed = input_text_values_match(expected_value, actual_value, input_type=input_type)+ if not committed and allow_autocomplete_rewrite:+ committed = _is_plausible_autocomplete_rewrite(expected_value, actual_value)+ return committed, actual_value, skyvern_element+++async def _verify_generic_input_commit_with_escalation(+ *,+ skyvern_element: SkyvernElement,+ skyvern_frame: SkyvernFrame,+ dom: DomUtil,+ tag_name: str,+ input_type: str,+ expected_value: str,+ allow_autocomplete_rewrite: bool,+) -> ActionFailure | None:+ # React-style inputs re-render nodes on every value change, so each escalation stage+ # gets its own re-resolve allowance instead of one shared across the ladder.+ committed, actual_value, skyvern_element = await _read_generic_input_commit(+ skyvern_element=skyvern_element,+ dom=dom,+ tag_name=tag_name,+ input_type=input_type,+ expected_value=expected_value,+ allow_autocomplete_rewrite=allow_autocomplete_rewrite,+ allow_reresolve=True,+ )+ if committed:+ return None++ # A masked or debounced field can land its value a beat after the keystrokes settle. Let it+ # before escalating, or the clear+retype below destroys a value that was about to commit.+ await skyvern_frame.safe_wait_for_animation_end(caller="input_text.commit_readback")+ committed, actual_value, skyvern_element = await _read_generic_input_commit(+ skyvern_element=skyvern_element,+ dom=dom,+ tag_name=tag_name,+ input_type=input_type,+ expected_value=expected_value,+ allow_autocomplete_rewrite=allow_autocomplete_rewrite,+ allow_reresolve=True,+ )+ if committed:+ return None++ await skyvern_element.input_clear()+ await skyvern_element.input_sequentially(text=expected_value)+ committed, actual_value, skyvern_element = await _read_generic_input_commit(+ skyvern_element=skyvern_element,+ dom=dom,+ tag_name=tag_name,+ input_type=input_type,+ expected_value=expected_value,+ allow_autocomplete_rewrite=allow_autocomplete_rewrite,+ allow_reresolve=True,+ )+ if committed:+ return None++ await skyvern_element.input_fill(text=expected_value)+ committed, actual_value, skyvern_element = await _read_generic_input_commit(+ skyvern_element=skyvern_element,+ dom=dom,+ tag_name=tag_name,+ input_type=input_type,+ expected_value=expected_value,+ allow_autocomplete_rewrite=allow_autocomplete_rewrite,+ allow_reresolve=True,+ )+ if committed:+ return None++ await skyvern_element.get_locator().evaluate(_SET_NATIVE_INPUT_VALUE_JS, expected_value)+ committed, actual_value, skyvern_element = await _read_generic_input_commit(+ skyvern_element=skyvern_element,+ dom=dom,+ tag_name=tag_name,+ input_type=input_type,+ expected_value=expected_value,+ allow_autocomplete_rewrite=allow_autocomplete_rewrite,+ allow_reresolve=True,+ )+ if committed:+ return None++ expected_length = len(_normalize_input_text_value(expected_value))+ actual_length = len(_normalize_input_text_value(actual_value))+ LOG.warning(+ "Input text commit mismatch after fallback ladder",+ element_id=skyvern_element.get_id(),+ expected_length=expected_length,+ actual_length=actual_length,+ )+ return ActionFailure(InputTextCommitMismatch(expected_length=expected_length, actual_length=actual_length))+++async def _verify_generic_input_commit(+ *,+ skyvern_element: SkyvernElement,+ skyvern_frame: SkyvernFrame,+ dom: DomUtil,+ tag_name: str,+ input_type: str,+ expected_value: str,+ allow_autocomplete_rewrite: bool = False,+) -> ActionFailure | None:+ try:+ return await _verify_generic_input_commit_with_escalation(+ skyvern_element=skyvern_element,+ skyvern_frame=skyvern_frame,+ dom=dom,+ tag_name=tag_name,+ input_type=input_type,+ expected_value=expected_value,+ allow_autocomplete_rewrite=allow_autocomplete_rewrite,+ )+ except PlaywrightError as exc:+ if _is_input_commit_navigation_error(exc):+ return None+ if _is_input_commit_detached_error(exc):+ LOG.info(+ "Element detached during input commit verification; skipping verification",+ element_id=skyvern_element.get_id(),+ )+ return None+ raise+++def _is_generic_input_commit_candidate(*, tag_name: str, live_input_type: str) -> str | None:+ if tag_name == "textarea":+ return "textarea"+ if tag_name != InteractiveElement.INPUT:+ return None+ return live_input_type if live_input_type not in _NON_TEXT_INPUT_TYPES else None++async def _log_tel_fallback_fill_digit_counts(*, skyvern_element: SkyvernElement, tag_name: str, expected_value: str, task_id: str | None, step_id: str | None) -> None:@@ -3687,6 +3961,7 @@ async def handle_input_text_action(incremental_element: list[dict] = []auto_complete_hacky_flag: bool = False+ autocomplete_option_signal: bool = Falseinput_or_select_context = await _get_input_or_select_context(action=action,@@ -3854,7 +4129,8 @@ async def handle_input_text_action()return [ActionFailure(InputToReadonlyElement(element_id=skyvern_element.get_id()))]- is_tel = await skyvern_element.get_attr("type") == "tel"+ live_input_type = ((await skyvern_element.get_attr("type")) or "text").lower()+ is_tel = live_input_type == "tel"candidate_card_digits = _card_number_digits(text)is_card_number_input = _is_probable_card_number(candidate_card_digits) and await _is_card_number_field(skyvern_element@@ -3958,8 +4234,11 @@ async def handle_input_text_action("Find a blocking element to the current element, going to input on the blocking element",)if await blocking_element.is_editable():+ blocking_tag_name = blocking_element.get_tag_name()+ blocking_input_type = ((await blocking_element.get_attr("type")) or "text").lower()skyvern_element = blocking_element- tag_name = blocking_element.get_tag_name()+ tag_name = blocking_tag_name+ live_input_type = blocking_input_typeexcept Exception:LOG.info("Failed to find the blocking element, continue with the original element",@@ -4010,7 +4289,7 @@ async def handle_input_text_action(if len(text) == 0:return [ActionSuccess()]- if tag_name == InteractiveElement.INPUT and await skyvern_element.get_attr("type") == "date":+ if tag_name == InteractiveElement.INPUT and live_input_type == "date":try:action.set_has_mini_agent()text = await check_date_format(@@ -4076,7 +4355,14 @@ async def handle_input_text_action()verify_masked_input_after_fill = True+ generic_commit_input_type = None+ if not is_tel and not card_expected_digits and await _is_input_text_commit_verification_enabled(task):+ generic_commit_input_type = _is_generic_input_commit_candidate(+ tag_name=tag_name,+ live_input_type=live_input_type,+ )await incremental_scraped.start_listen_dom_increment(await skyvern_element.get_element_handler())+ input_context_destroyed = Falsetry:if card_expected_digits:@@ -4158,6 +4444,7 @@ async def handle_input_text_action()if len(incremental_element) > 0:auto_complete_hacky_flag = True+ autocomplete_option_signal = _incremental_elements_contain_option_ui(incremental_element)if (input_or_select_contextand input_or_select_context.is_search_bar@@ -4166,7 +4453,6 @@ async def handle_input_text_action(LOG.info("Detected target-matching dropdown after search-bar input; attempting custom selection",element_id=skyvern_element.get_id(),- target_value=text,)action.set_has_mini_agent()select_result = await sequentially_select_from_dropdown(@@ -4236,6 +4522,7 @@ async def handle_input_text_action(or "navigation" in error_messageor "target closed" in error_message):+ input_context_destroyed = True# These are expected during page navigation/auto-submit, silently continueLOG.debug("Playwright error during incremental element processing (likely page navigation)",@@ -4260,6 +4547,19 @@ async def handle_input_text_action(# Always stop listeningawait incremental_scraped.stop_listen_dom_increment()+ if generic_commit_input_type is not None and not input_context_destroyed:+ commit_failure = await _verify_generic_input_commit(+ skyvern_element=skyvern_element,+ skyvern_frame=skyvern_frame,+ dom=dom,+ tag_name=tag_name,+ input_type=generic_commit_input_type,+ expected_value=text,+ allow_autocomplete_rewrite=autocomplete_option_signal,+ )+ if commit_failure is not None:+ return [commit_failure]+return [ActionSuccess()]except Exception as e:# Handle any other unexpected errors during text inputdiff --git a/tests/unit/test_agent_step_characterization.py b/tests/unit/test_agent_step_characterization.pyindex cad0ad6d7..14a170b3a 100644--- a/tests/unit/test_agent_step_characterization.py+++ b/tests/unit/test_agent_step_characterization.py@@ -9,13 +9,14 @@ from zoneinfo import ZoneInfoimport pytest-from skyvern.exceptions import NoTOTPVerificationCodeFound-from skyvern.forge.agent import ForgeAgent, StepPromptResult+from skyvern.exceptions import NoTOTPVerificationCodeFound, RepeatedActionFailure+from skyvern.forge.agent import ForgeAgent, StepPromptResult, _get_repeated_action_failurefrom skyvern.forge.sdk.core import skyvern_contextfrom skyvern.forge.sdk.core.skyvern_context import SkyvernContextfrom skyvern.forge.sdk.models import Step, StepStatusfrom skyvern.forge.sdk.schemas.organizations import Organizationfrom skyvern.forge.sdk.schemas.tasks import Task+from skyvern.schemas.steps import AgentStepOutputfrom skyvern.webeye.actions.action_types import ActionTypefrom skyvern.webeye.actions.actions import (Action,@@ -23,6 +24,7 @@ from skyvern.webeye.actions.actions import (CompleteAction,DownloadFileAction,ExtractAction,+ InputTextAction,WaitAction,)from skyvern.webeye.actions.models import DetailedAgentStepOutput@@ -77,6 +79,7 @@ def make_agent_step_rig(injected_actions: list[Action] | None = None,task_overrides: dict[str, Any] | None = None,disable_user_goal_check: bool = True,+ repeated_action_breaker: bool = False,) -> AgentStepRig:agent = ForgeAgent()now = datetime.now(UTC)@@ -148,6 +151,8 @@ def make_agent_step_rig(async def _flag(flag_name: str, *_args, **_kwargs) -> bool:if flag_name == "DISABLE_USER_GOAL_CHECK":return disable_user_goal_check+ if flag_name == "REPEATED_ACTION_CIRCUIT_BREAKER":+ return repeated_action_breakerreturn Falsemonkeypatch.setattr(@@ -284,6 +289,137 @@ async def test_failed_action_marks_step_failed_and_skips_remaining(monkeypatch:assert output.actions_and_results[0][1][0].success is False+async def test_third_identical_failed_persisted_input_surfaces_repeated_action_failure(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ action = InputTextAction(element_id="framework-managed-input", text="private payload")+ handler = AsyncMock(+ return_value=[ActionFailure(Exception("value did not commit"), stop_execution_on_failure=False)]+ )+ rig = make_agent_step_rig(+ monkeypatch, parsed_actions=[action], action_handler=handler, repeated_action_breaker=True+ )+ previous_steps = []+ for order in range(2):+ previous_action = action.model_copy(update={"step_id": f"step-{order}", "step_order": order})+ persisted_output = AgentStepOutput.model_validate(+ AgentStepOutput(+ action_results=[ActionFailure(Exception("value did not commit"), stop_execution_on_failure=False)],+ actions_and_results=[+ (+ previous_action,+ [ActionFailure(Exception("value did not commit"), stop_execution_on_failure=False)],+ ),+ ],+ errors=[],+ ).model_dump(mode="json")+ )+ assert persisted_output.actions_and_results is not None+ persisted_action = persisted_output.actions_and_results[0][0]+ assert type(persisted_action) is Action+ assert persisted_action.action_type == ActionType.INPUT_TEXT+ assert persisted_action.element_id == "framework-managed-input"+ assert persisted_action.text == "private payload"+ previous_step = make_step(+ datetime.now(UTC),+ rig.task,+ step_id=f"step-{order}",+ status=StepStatus.failed,+ order=order,+ output=persisted_output,+ )+ previous_steps.append(previous_step)+ monkeypatch.setattr(+ "skyvern.forge.agent.app.DATABASE.tasks.get_task_steps",+ AsyncMock(return_value=previous_steps),+ )++ step, output = await rig.run()++ assert step.status == StepStatus.completed+ assert handler.await_count == 1+ assert output.actions_and_results is not None+ repeated_result = output.actions_and_results[-1][1][-1]+ assert repeated_result.exception_type == RepeatedActionFailure.__name__+ assert "framework-managed-input" in (repeated_result.exception_message or "")+ assert "3" in (repeated_result.exception_message or "")+ assert "Exception" in (repeated_result.exception_message or "")+ assert "private payload" not in (repeated_result.exception_message or "")+ assert repeated_result.stop_execution_on_failure is False+++async def test_repeat_ineligible_failure_does_not_load_task_history(monkeypatch: pytest.MonkeyPatch) -> None:+ action = WaitAction(seconds=1)+ history = AsyncMock()+ monkeypatch.setattr("skyvern.forge.agent.app.DATABASE.tasks.get_task_steps", history)+ rig = make_agent_step_rig(+ monkeypatch,+ parsed_actions=[action],+ action_handler=AsyncMock(return_value=[ActionFailure(Exception("failed"))]),+ )++ await rig.run()++ history.assert_not_awaited()+++async def test_repeated_action_breaker_disabled_adds_no_db_read_and_no_failure(+ monkeypatch: pytest.MonkeyPatch,+) -> None:+ """Flag off is today's behavior: the failure surfaces as itself and the task-steps history is never+ loaded, so a flag-off org pays nothing for the detector on the failing-action hot path."""+ action = InputTextAction(element_id="framework-managed-input", text="private payload")+ history = AsyncMock(return_value=[])+ monkeypatch.setattr("skyvern.forge.agent.app.DATABASE.tasks.get_task_steps", history)+ rig = make_agent_step_rig(+ monkeypatch,+ parsed_actions=[action, action.model_copy(), action.model_copy()],+ action_handler=AsyncMock(+ return_value=[ActionFailure(Exception("value did not commit"), stop_execution_on_failure=False)]+ ),+ repeated_action_breaker=False,+ )++ _, output = await rig.run()++ history.assert_not_awaited()+ for _action, results in output.actions_and_results:+ assert results[-1].exception_type == "Exception"+ assert results[-1].exception_type != RepeatedActionFailure.__name__+++async def test_repeated_action_history_loaded_at_most_once_per_step(monkeypatch: pytest.MonkeyPatch) -> None:+ action = InputTextAction(element_id="framework-managed-input", text="private payload")+ history = AsyncMock(return_value=[])+ monkeypatch.setattr("skyvern.forge.agent.app.DATABASE.tasks.get_task_steps", history)+ rig = make_agent_step_rig(+ monkeypatch,+ parsed_actions=[action, action.model_copy()],+ action_handler=AsyncMock(+ return_value=[ActionFailure(Exception("value did not commit"), stop_execution_on_failure=False)]+ ),+ repeated_action_breaker=True,+ )++ await rig.run()++ assert rig.action_handler.await_count == 2+ assert history.await_count == 1+++def test_repeated_action_failure_requires_matching_unsuccessful_attempts() -> None:+ first = InputTextAction(element_id="field", text="first")+ second = InputTextAction(element_id="field", text="second")+ failure = [ActionFailure(Exception("failed"))]++ assert _get_repeated_action_failure([(first, failure), (first, [ActionSuccess()]), (first, failure)]) is None+ assert _get_repeated_action_failure([(first, failure), (second, failure), (first, failure)]) is None++@pytest.mark.asyncioasync def test_failed_action_with_continue_flag_executes_remaining(monkeypatch: pytest.MonkeyPatch) -> None:# Mirror of the skip case: a failure result that opts out of stopping the batchdiff --git a/tests/unit/test_input_text_combobox_commit.py b/tests/unit/test_input_text_combobox_commit.pyindex a927b8592..a8984d5ce 100644--- a/tests/unit/test_input_text_combobox_commit.py+++ b/tests/unit/test_input_text_combobox_commit.py@@ -206,6 +206,10 @@ async def _run_combobox_input(),patch("skyvern.webeye.actions.handler._get_input_or_select_context", new=AsyncMock(return_value=context)),patch("skyvern.webeye.actions.handler.sequentially_select_from_dropdown", new=select_mock),+ patch(+ "skyvern.webeye.actions.handler._is_input_text_commit_verification_enabled",+ new=AsyncMock(return_value=False),+ ),):results = await handle_input_text_action(action=action, page=MagicMock(), scraped_page=scraped_page, task=_TASK, step=_STEPdiff --git a/tests/unit/test_input_text_phone_readback.py b/tests/unit/test_input_text_phone_readback.pyindex 0dcd3b982..031cd3b58 100644--- a/tests/unit/test_input_text_phone_readback.py+++ b/tests/unit/test_input_text_phone_readback.py@@ -3,13 +3,17 @@ from __future__ import annotationsfrom unittest.mock import AsyncMock, MagicMockimport pytest+from playwright._impl._errors import Error as PlaywrightError-from skyvern.exceptions import PhoneNumberInputMismatch+from skyvern.exceptions import InputTextCommitMismatch, PhoneNumberInputMismatchfrom skyvern.webeye.actions.handler import (_fill_nanp_tel_with_readback,_log_tel_fallback_fill_digit_counts,+ _verify_generic_input_commit,+ input_text_values_match,verify_phone_input_digits,)+from skyvern.webeye.actions.responses import ActionFailureNANP_DIGITS = "2245550199"NANP_E164 = f"+1{NANP_DIGITS}"@@ -163,3 +167,328 @@ async def test_tel_fallback_digit_count_log_swallows_read_errors() -> None:task_id="tsk_1",step_id="stp_1",)+++ ("expected", "actual", "input_type"),+ [+ ("5551234567", "(555) 123-4567", "text"),+ ("12345", "12345-____", "text"),+ ("ab12 cd", "AB12-CD", "search"),+ ("postal code", "POSTAL_CODE", "textarea"),+ ],+)+def test_input_text_values_match_ignores_plain_text_mask_formatting(+ expected: str, actual: str, input_type: str+) -> None:+ assert input_text_values_match(expected, actual, input_type=input_type)+++ ("expected", "actual", "input_type"),+ [+ ("[email protected]", "user@exampletest", "email"),+ ("https://example.test/path", "https://exampletest/path", "url"),+ ("-12.5", "125", "number"),+ ],+)+def test_input_text_values_match_preserves_semantic_punctuation(expected: str, actual: str, input_type: str) -> None:+ assert not input_text_values_match(expected, actual, input_type=input_type)+++def test_input_text_values_match_trims_semantic_input_whitespace() -> None:+ assert input_text_values_match(" [email protected] ", "[email protected]", input_type="email")+++ ("expected", "actual", "committed", "why"),+ [+ # A field has committed when its value derives from what was typed.+ ("12345", "12345", True, "exact"),+ ("1234567890", "(123) 456-7890", True, "reformat only rearranges separators"),+ ("12345", "12345-6789", True, "widget enriches the typed value"),+ ("foo_bar", "foo_bar", True, "placeholder char inside a fully typed value"),+ # Only these are failures.+ ("12345", "", False, "empty"),+ ("12345", "_____", False, "mask kept none of the keystrokes"),+ ("12345", "123__", False, "mask kept only some of them"),+ ("12345", "99999", False, "genuinely different value"),+ ("12345", "999123459", False, "contains the typed value but does not derive from it"),+ ("---", "___", True, "separators typed, separators back: a reformat of nothing"),+ ("---", "xyz", False, "separators typed, a real value back: not a reformat of it"),+ ],+)+def test_input_text_values_match_treats_derived_values_as_committed(+ expected: str, actual: str, committed: bool, why: str+) -> None:+ assert input_text_values_match(expected, actual, input_type="text") is committed, why+++def test_input_text_values_match_rejects_empty_commit() -> None:+ assert not input_text_values_match("-", "", input_type="text")+++def _make_commit_element(readbacks: list[str]) -> MagicMock:+ locator = MagicMock()+ locator.input_value = AsyncMock(side_effect=readbacks)+ locator.evaluate = AsyncMock()+ element = _make_element(locator)+ element.input_clear = AsyncMock()+ element.input_sequentially = AsyncMock()+ element.input_fill = AsyncMock()+ return element+++def _make_commit_frame() -> MagicMock:+ frame = MagicMock()+ frame.safe_wait_for_animation_end = AsyncMock()+ return frame+++async def test_generic_commit_verification_accepts_initial_readback() -> None:+ element = _make_commit_element(["committed"])+ dom = MagicMock()++ result = await _verify_generic_input_commit(+ skyvern_element=element,+ skyvern_frame=_make_commit_frame(),+ dom=dom,+ tag_name="input",+ input_type="text",+ expected_value="committed",+ )++ assert result is None+ element.input_clear.assert_not_awaited()+ element.input_fill.assert_not_awaited()+ element.get_locator().evaluate.assert_not_awaited()+++async def test_generic_commit_verification_settles_before_destroying_a_slow_value() -> None:+ # A masked or debounced field can land its value a beat after the keystrokes settle. Escalating on+ # the first read-back would clear and retype a field that was about to commit correctly.+ element = _make_commit_element(["", "committed"])+ frame = _make_commit_frame()+ dom = MagicMock()++ result = await _verify_generic_input_commit(+ skyvern_element=element,+ skyvern_frame=frame,+ dom=dom,+ tag_name="input",+ input_type="text",+ expected_value="committed",+ )++ assert result is None+ frame.safe_wait_for_animation_end.assert_awaited_once()+ element.input_clear.assert_not_awaited()+ element.input_sequentially.assert_not_awaited()+++async def test_generic_commit_verification_escalates_to_fill() -> None:+ element = _make_commit_element(["", "", "", "committed"])+ dom = MagicMock()++ result = await _verify_generic_input_commit(+ skyvern_element=element,+ skyvern_frame=_make_commit_frame(),+ dom=dom,+ tag_name="input",+ input_type="text",+ expected_value="committed",+ )++ assert result is None+ element.input_clear.assert_awaited_once()+ element.input_sequentially.assert_awaited_once_with(text="committed")+ element.input_fill.assert_awaited_once_with(text="committed")+ element.get_locator().evaluate.assert_not_awaited()+++async def test_generic_commit_verification_escalates_to_native_setter() -> None:+ element = _make_commit_element(["", "", "", "", "committed"])+ dom = MagicMock()++ result = await _verify_generic_input_commit(+ skyvern_element=element,+ skyvern_frame=_make_commit_frame(),+ dom=dom,+ tag_name="textarea",+ input_type="textarea",+ expected_value="committed",+ )++ assert result is None+ element.input_fill.assert_awaited_once_with(text="committed")+ element.get_locator().evaluate.assert_awaited_once()+ assert element.get_locator().evaluate.await_args.args[1] == "committed"+++async def test_generic_commit_verification_returns_typed_failure_without_value() -> None:+ element = _make_commit_element(["", "", "", "", ""])+ dom = MagicMock()++ result = await _verify_generic_input_commit(+ skyvern_element=element,+ skyvern_frame=_make_commit_frame(),+ dom=dom,+ tag_name="input",+ input_type="text",+ expected_value="sensitive-value",+ )++ assert isinstance(result, ActionFailure)+ assert result.exception_type == InputTextCommitMismatch.__name__+ assert "expected length 14" in (result.exception_message or "")+ assert "actual length 0" in (result.exception_message or "")+ assert "sensitive-value" not in (result.exception_message or "")+++async def test_generic_commit_verification_skips_navigation_during_escalation() -> None:+ element = _make_commit_element(["", ""])+ dom = MagicMock()+ element.input_clear.side_effect = PlaywrightError("Execution context was destroyed during navigation")++ result = await _verify_generic_input_commit(+ skyvern_element=element,+ skyvern_frame=_make_commit_frame(),+ dom=dom,+ tag_name="input",+ input_type="text",+ expected_value="committed",+ )++ assert result is None+++async def test_generic_commit_verification_reresolves_detached_element() -> None:+ detached_element = _make_commit_element([])+ detached_element.get_locator().input_value.side_effect = PlaywrightError("Element is not attached to the DOM")+ replacement_element = _make_commit_element(["committed"])+ dom = MagicMock()+ dom.get_skyvern_element_by_id = AsyncMock(return_value=replacement_element)++ result = await _verify_generic_input_commit(+ skyvern_element=detached_element,+ skyvern_frame=_make_commit_frame(),+ dom=dom,+ tag_name="input",+ input_type="text",+ expected_value="committed",+ )++ assert result is None+ dom.get_skyvern_element_by_id.assert_awaited_once_with(detached_element.get_id())+++async def test_generic_commit_verification_accepts_plausible_autocomplete_rewrite() -> None:+ element = _make_commit_element(["committed option"])++ result = await _verify_generic_input_commit(+ skyvern_element=element,+ skyvern_frame=_make_commit_frame(),+ dom=MagicMock(),+ tag_name="input",+ input_type="text",+ expected_value="committed",+ allow_autocomplete_rewrite=True,+ )++ assert result is None+ element.input_clear.assert_not_awaited()+++async def test_generic_commit_verification_rejects_truncated_value_as_autocomplete_rewrite() -> None:+ element = _make_commit_element(["123", "123", "123", "123", "123"])++ result = await _verify_generic_input_commit(+ skyvern_element=element,+ skyvern_frame=_make_commit_frame(),+ dom=MagicMock(),+ tag_name="input",+ input_type="text",+ expected_value="12345",+ allow_autocomplete_rewrite=True,+ )++ assert isinstance(result, ActionFailure)+ assert result.exception_type == InputTextCommitMismatch.__name__+ element.input_clear.assert_awaited_once()+ element.input_fill.assert_awaited_once_with(text="12345")+++async def test_generic_commit_verification_escalates_garbled_readback_without_rewrite_allowance() -> None:+ element = _make_commit_element(["123", "123", "12345"])++ result = await _verify_generic_input_commit(+ skyvern_element=element,+ skyvern_frame=_make_commit_frame(),+ dom=MagicMock(),+ tag_name="input",+ input_type="text",+ expected_value="12345",+ )++ assert result is None+ element.input_clear.assert_awaited_once()+ element.input_sequentially.assert_awaited_once_with(text="12345")+++async def test_generic_commit_verification_reresolves_once_per_escalation_stage() -> None:+ first_element = _make_commit_element([])+ first_element.get_locator().input_value.side_effect = PlaywrightError("Element is not attached to the DOM")+ second_element = _make_commit_element([])+ second_element.get_locator().input_value.side_effect = [+ "",+ "",+ PlaywrightError("Element is not attached to the DOM"),+ ]+ third_element = _make_commit_element(["committed"])+ dom = MagicMock()+ dom.get_skyvern_element_by_id = AsyncMock(side_effect=[second_element, third_element])++ result = await _verify_generic_input_commit(+ skyvern_element=first_element,+ skyvern_frame=_make_commit_frame(),+ dom=dom,+ tag_name="input",+ input_type="text",+ expected_value="committed",+ )++ assert result is None+ assert dom.get_skyvern_element_by_id.await_count == 2+ second_element.input_sequentially.assert_awaited_once_with(text="committed")+++async def test_generic_commit_verification_soft_skips_detach_during_fill_stage() -> None:+ detached_element = _make_commit_element([])+ detached_element.get_locator().input_value.side_effect = PlaywrightError("Element is not attached to the DOM")+ replacement_element = _make_commit_element(["", ""])+ replacement_element.input_clear.side_effect = PlaywrightError("Element is not attached to the DOM")+ dom = MagicMock()+ dom.get_skyvern_element_by_id = AsyncMock(return_value=replacement_element)++ result = await _verify_generic_input_commit(+ skyvern_element=detached_element,+ skyvern_frame=_make_commit_frame(),+ dom=dom,+ tag_name="input",+ input_type="text",+ expected_value="committed",+ )++ assert result is Nonediff --git a/tests/unit/test_input_text_search_bar_skip.py b/tests/unit/test_input_text_search_bar_skip.pyindex 06fd5e3cc..edb9edb90 100644--- a/tests/unit/test_input_text_search_bar_skip.py+++ b/tests/unit/test_input_text_search_bar_skip.py@@ -122,6 +122,10 @@ async def _run_search_bar_input(stop_flag: bool, incremental: list[dict]) -> lis"skyvern.webeye.actions.handler.sequentially_select_from_dropdown",new=AsyncMock(return_value=select_result),),+ patch(+ "skyvern.webeye.actions.handler._is_input_text_commit_verification_enabled",+ new=AsyncMock(return_value=False),+ ),):return await handle_input_text_action(action=action, page=MagicMock(), scraped_page=scraped_page, task=_TASK, step=_STEPdiff --git a/tests/unit/test_input_text_tel_card_routing.py b/tests/unit/test_input_text_tel_card_routing.pyindex e18b72054..802dd56b6 100644--- a/tests/unit/test_input_text_tel_card_routing.py+++ b/tests/unit/test_input_text_tel_card_routing.py@@ -1,7 +1,7 @@from __future__ import annotationsfrom datetime import UTC, datetime-from unittest.mock import AsyncMock, MagicMock, patch+from unittest.mock import ANY, AsyncMock, MagicMock, patchimport pytest@@ -53,14 +53,16 @@ async def _run_input_text(*,tel_fix_enabled: bool = True,tel_verify_side_effect: list[Exception | None] | None = None,-) -> tuple[list, AsyncMock, AsyncMock, AsyncMock, MagicMock]:+ generic_flag: bool = True,+ incremental_elements: list[dict] | None = None,+) -> tuple[list, AsyncMock, AsyncMock, AsyncMock, MagicMock, AsyncMock]:dom_instance = MagicMock()dom_instance.get_skyvern_element_by_id = AsyncMock(return_value=el)inc = MagicMock()inc.start_listen_dom_increment = AsyncMock()inc.stop_listen_dom_increment = AsyncMock()- inc.get_incremental_element_tree = AsyncMock(return_value=[])+ inc.get_incremental_element_tree = AsyncMock(return_value=incremental_elements or [])skyvern_frame = MagicMock()skyvern_frame.safe_wait_for_animation_end = AsyncMock()@@ -70,6 +72,7 @@ async def _run_input_text(card_readback = AsyncMock(return_value=None)tel_verify = AsyncMock(side_effect=tel_verify_side_effect)+ generic_verify = AsyncMock(return_value=None)phone_format = AsyncMock(return_value=text)warning_log = MagicMock()@@ -81,9 +84,15 @@ async def _run_input_text(patch("skyvern.webeye.actions.handler.get_actual_value_of_parameter_if_secret_with_task", return_value=text),patch("skyvern.webeye.actions.handler._get_input_or_select_context", new=AsyncMock(return_value=None)),patch("skyvern.webeye.actions.handler._is_tel_digit_fix_enabled", new=AsyncMock(return_value=tel_fix_enabled)),+ patch(+ "skyvern.webeye.actions.handler._is_input_text_commit_verification_enabled",+ new=AsyncMock(return_value=generic_flag),+ ),patch("skyvern.webeye.actions.handler.check_phone_number_format", new=phone_format),patch("skyvern.webeye.actions.handler._fill_card_number_with_readback", new=card_readback),patch("skyvern.webeye.actions.handler._verify_tel_input_after_fill", new=tel_verify),+ patch("skyvern.webeye.actions.handler._verify_generic_input_commit", new=generic_verify),+ patch("skyvern.webeye.actions.handler.check_date_format", new=AsyncMock(return_value=text)),patch("skyvern.webeye.actions.handler.LOG.warning", new=warning_log),):results = await handle_input_text_action(@@ -94,7 +103,7 @@ async def _run_input_text(step=_STEP,)- return results, card_readback, tel_verify, phone_format, warning_log+ return results, card_readback, tel_verify, phone_format, warning_log, generic_verify@pytest.mark.asyncio@@ -108,7 +117,7 @@ async def _run_input_text(async def test_tel_card_number_field_uses_card_readback_not_phone_format(attrs: dict[str, str | None]) -> None:el = _mock_input(attrs)- results, card_readback, tel_verify, phone_format, _ = await _run_input_text(el, VISA_16)+ results, card_readback, tel_verify, phone_format, _, generic_verify = await _run_input_text(el, VISA_16)assert len(results) == 1 and isinstance(results[0], ActionSuccess)card_readback.assert_awaited_once_with(@@ -119,6 +128,7 @@ async def test_tel_card_number_field_uses_card_readback_not_phone_format(attrs:)phone_format.assert_not_awaited()tel_verify.assert_not_awaited()+ generic_verify.assert_not_awaited()el.input_sequentially.assert_not_awaited()@@ -126,7 +136,7 @@ async def test_tel_card_number_field_uses_card_readback_not_phone_format(attrs:async def test_ten_digit_tel_phone_uses_tel_readback_not_card_readback() -> None:el = _mock_input({"type": "tel", "autocomplete": None, "name": "phone"})- results, card_readback, tel_verify, phone_format, _ = await _run_input_text(el, "224-555-0199")+ results, card_readback, tel_verify, phone_format, _, generic_verify = await _run_input_text(el, "224-555-0199")assert len(results) == 1 and isinstance(results[0], ActionSuccess)el.input_sequentially.assert_awaited_once_with(text="2245550199")@@ -138,13 +148,14 @@ async def test_ten_digit_tel_phone_uses_tel_readback_not_card_readback() -> None)card_readback.assert_not_awaited()phone_format.assert_not_awaited()+ generic_verify.assert_not_awaited()@pytest.mark.asyncioasync def test_tel_flag_off_preserves_legacy_format_and_sequential_fill() -> None:el = _mock_input({"type": "tel", "autocomplete": None, "name": "phone"})- results, _, tel_verify, phone_format, _ = await _run_input_text(+ results, _, tel_verify, phone_format, _, _ = await _run_input_text(el,"224-555-0199",tel_fix_enabled=False,@@ -166,7 +177,7 @@ async def test_separator_only_tel_never_forces_nanp_country_code() -> None:PhoneNumberInputMismatch(expected_digit_count=10, actual_digit_count=12),]- results, _, tel_verify, _, warning_log = await _run_input_text(+ results, _, tel_verify, _, warning_log, _ = await _run_input_text(el,"224-555-0199",tel_verify_side_effect=mismatches,@@ -194,7 +205,7 @@ async def test_explicit_nanp_tel_keeps_constraint_safe_e164_fallback() -> None:None,]- results, _, tel_verify, _, _ = await _run_input_text(+ results, _, tel_verify, _, _, _ = await _run_input_text(el,"+1 (224) 555-0199",tel_verify_side_effect=mismatches_then_success,@@ -208,3 +219,99 @@ async def test_explicit_nanp_tel_keeps_constraint_safe_e164_fallback() -> None:"2245550199","+12245550199",]+++async def test_generic_text_input_runs_commit_verification() -> None:+ el = _mock_input({"type": "text", "autocomplete": None, "name": "postal_code"})++ results, card_readback, tel_verify, phone_format, _, generic_verify = await _run_input_text(el, "12345")++ assert len(results) == 1 and isinstance(results[0], ActionSuccess)+ el.input_sequentially.assert_awaited_once_with(text="12345")+ generic_verify.assert_awaited_once_with(+ skyvern_element=el,+ skyvern_frame=ANY,+ dom=ANY,+ tag_name="input",+ input_type="text",+ expected_value="12345",+ allow_autocomplete_rewrite=False,+ )+ card_readback.assert_not_awaited()+ tel_verify.assert_not_awaited()+ phone_format.assert_not_awaited()+++async def test_blocking_date_input_refreshes_type_before_routing() -> None:+ original = _mock_input({"type": "text", "autocomplete": None, "name": "start_date"})+ blocking = _mock_input({"type": "date", "autocomplete": None, "name": "start_date"})+ blocking.get_id.return_value = "BLOCKING"+ original.find_blocking_element = AsyncMock(return_value=(blocking, True))++ results, _, _, _, _, generic_verify = await _run_input_text(original, "2026-07-17")++ assert len(results) == 1 and isinstance(results[0], ActionSuccess)+ blocking.input_fill.assert_awaited_once_with(text="2026-07-17")+ blocking.input_sequentially.assert_not_awaited()+ generic_verify.assert_not_awaited()+++async def test_generic_text_input_skips_commit_verification_when_flag_disabled() -> None:+ el = _mock_input({"type": "text", "autocomplete": None, "name": "postal_code"})++ results, _, _, _, _, generic_verify = await _run_input_text(el, "12345", generic_flag=False)++ assert len(results) == 1 and isinstance(results[0], ActionSuccess)+ el.input_sequentially.assert_awaited_once_with(text="12345")+ generic_verify.assert_not_awaited()+ type_queries = [call for call in el.get_attr.await_args_list if call.args == ("type",)]+ assert len(type_queries) == 1+++async def test_generic_text_input_verifies_after_unrelated_dom_mutation() -> None:+ el = _mock_input({"type": "text", "autocomplete": None, "name": "postal_code"})++ results, _, _, _, _, generic_verify = await _run_input_text(+ el,+ "12345",+ incremental_elements=[{"tagName": "div", "attributes": {"class": "field-error"}, "children": []}],+ )++ assert len(results) == 1 and isinstance(results[0], ActionSuccess)+ generic_verify.assert_awaited_once()+ assert generic_verify.await_args.kwargs["allow_autocomplete_rewrite"] is False+++async def test_generic_text_input_allows_autocomplete_rewrite_for_option_mutation() -> None:+ el = _mock_input({"type": "text", "autocomplete": None, "name": "postal_code"})++ results, _, _, _, _, generic_verify = await _run_input_text(+ el,+ "12345",+ incremental_elements=[+ {+ "tagName": "ul",+ "attributes": {"role": "listbox"},+ "children": [{"tagName": "li", "attributes": {"role": "option"}, "children": []}],+ }+ ],+ )++ assert len(results) == 1 and isinstance(results[0], ActionSuccess)+ generic_verify.assert_awaited_once()+ assert generic_verify.await_args.kwargs["allow_autocomplete_rewrite"] is True+++async def test_password_input_skips_commit_verification() -> None:+ el = _mock_input({"type": "password", "autocomplete": None, "name": "credential"})++ results, _, _, _, _, generic_verify = await _run_input_text(el, "private payload")++ assert len(results) == 1 and isinstance(results[0], ActionSuccess)+ generic_verify.assert_not_awaited()