Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(SKY-9276): let the v1 planner emit EXTRACT_INFORMATION and GOTO_URL (#6800)
Suchintanb07fed53936f
diff --git a/skyvern/forge/agent.py b/skyvern/forge/agent.pyindex b824cd409..0dd1bf721 100644--- a/skyvern/forge/agent.py+++ b/skyvern/forge/agent.py@@ -2073,9 +2073,15 @@ class ForgeAgent:# if the last action is complete and is successful, check if there's a data extraction goal# if task has navigation goal and extraction goal at the same time, handle ExtractAction before marking step as completed+ # skip when the step already ran a successful planner-emitted EXTRACT action — re-extracting would be a duplicate+ step_has_successful_extract = any(+ executed_action.action_type == ActionType.EXTRACT and any(result.success for result in results)+ for executed_action, results in detailed_agent_step_output.actions_and_results+ )if (task.navigation_goaland task.data_extraction_goal+ and not step_has_successful_extractand self.step_has_completed_goal(detailed_agent_step_output)):working_page = await browser_state.must_get_working_page()@@ -3550,11 +3556,13 @@ class ForgeAgent:enriched_tree_enabled: bool = False,llm_screenshots_enabled: bool = True,slim_output: str | None = None,+ has_data_extraction_goal: bool = False,+ enable_new_planner_actions: bool = False,) -> str:"""Build a short-but-unique cache variant identifier so extract-action prompts that- differ meaningfully (OTP, close-page availability, complete criteria, slim output)- do not reuse the same Vertex cache object.+ differ meaningfully (OTP, close-page availability, complete criteria, slim output,+ data extraction goal availability, new planner actions) do not reuse the same Vertex cache object."""variant_parts: list[str] = []if verification_code_check:@@ -3565,6 +3573,10 @@ class ForgeAgent:variant_parts.append("nt")if show_switch_tab_action:variant_parts.append("st")+ if has_data_extraction_goal:+ variant_parts.append("de")+ if enable_new_planner_actions:+ variant_parts.append("np")if enriched_tree_enabled:variant_parts.append("et")if enriched_tree_enabled and not llm_screenshots_enabled:@@ -3847,6 +3859,14 @@ class ForgeAgent:llm_screenshots_enabled = context.llm_screenshots_enabled_for_prompt(retry_index=step.retry_index)enriched_tree_enabled = context.enriched_tree_enabled()+ # Off keeps pre-PR behavior: the planner is never offered these actions, so the parser and+ # is_goal_achieved branches stay dormant. Per-run randomization, like DISABLE_USER_GOAL_CHECK.+ enable_new_planner_actions = await app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached(+ "ENABLE_NEW_PLANNER_ACTIONS",+ task.workflow_run_id if task.workflow_run_id else task.task_id,+ properties={"task_url": task.url, "organization_id": task.organization_id},+ )+# Format-then-clear so a render failure can't drop the signal permanently;# gate on extract-action template since other task types don't render it.recent_dialog_messages_str = (@@ -3862,6 +3882,7 @@ class ForgeAgent:"starting_url": starting_url,"current_url": current_url,"data_extraction_goal": task.data_extraction_goal,+ "enable_new_planner_actions": enable_new_planner_actions,"action_history": actions_and_results_str,"error_code_mapping_str": (json.dumps(task.error_code_mapping) if task.error_code_mapping else None@@ -3888,6 +3909,8 @@ class ForgeAgent:enriched_tree_enabled=enriched_tree_enabled,llm_screenshots_enabled=llm_screenshots_enabled,slim_output=slim_output,+ has_data_extraction_goal=bool(task.data_extraction_goal),+ enable_new_planner_actions=enable_new_planner_actions,)static_prompt = prompt_engine.load_prompt(f"{template}-static", **prompt_kwargs)dynamic_prompt = prompt_engine.load_prompt(@@ -3967,6 +3990,7 @@ class ForgeAgent:starting_url=starting_url,current_url=current_url,data_extraction_goal=task.data_extraction_goal,+ enable_new_planner_actions=enable_new_planner_actions,action_history=actions_and_results_str,error_code_mapping_str=(json.dumps(task.error_code_mapping) if task.error_code_mapping else None),local_datetime=datetime.now(context.tz_info).isoformat(),@@ -5716,7 +5740,7 @@ class ForgeAgent:task_completes_on_download = task_block and task_block.complete_on_download and task.workflow_run_idshould_verify = (complete_verification- and not step.is_goal_achieved()+ and not step.is_goal_achieved(has_navigation_goal=bool(task.navigation_goal))and not step.is_terminated()and not isinstance(task_block, ActionBlock)and not task_completes_on_download@@ -5748,7 +5772,7 @@ class ForgeAgent:task_block=task_block,)- if step.is_goal_achieved():+ if step.is_goal_achieved(has_navigation_goal=bool(task.navigation_goal)):LOG.info("Step completed and goal achieved, marking task as completed",step_order=step.order,diff --git a/skyvern/forge/prompts/skyvern/extract-action-static.j2 b/skyvern/forge/prompts/skyvern/extract-action-static.j2index 6f0f1e091..6ea7958bc 100644--- a/skyvern/forge/prompts/skyvern/extract-action-static.j2+++ b/skyvern/forge/prompts/skyvern/extract-action-static.j2@@ -21,14 +21,18 @@ Reply in JSON format with the following keys:"user_detail_query": str, // Think of this value as a Jeopardy question and the intention behind the action. Ask the user for the details you need for executing this action. IMPORTANT: This question must be user information agnostic and must NOT contain specific user data (like names, IDs, specific values, etc.). Ask what information is needed generically. Ask the question even if the details are disclosed in user goal or user details. If it's a text field, ask for the text. If it's a file upload, ask for the file. If it's a dropdown, ask for the relevant information. If you are clicking on something specific, ask about what the intention is behind the click and what to click on. If you're downloading a file and you have multiple options, ask the user which one to download. Examples are: "What product ID should I input into the search bar?", "What file should I upload?", "What is the previous insurance provider of the user?", "Which invoice should I download?", "Does the user have any pets?", "Which member should I take action on?". NEVER include specific user data in this question - keep it generic so it can be answered with different user contexts."user_detail_answer": str, // The answer to the `user_detail_query`. The source of this answer can be user goal or user details. This answer CAN contain specific user data."confidence_float": float, // The confidence of the action. Pick a number between 0.0 and 1.0. 0.0 means no confidence, 1.0 means full confidence- "action_type": str, // It's a string enum: "CLICK", "HOVER", "INPUT_TEXT", "UPLOAD_FILE", "SELECT_OPTION", "WAIT", "SOLVE_CAPTCHA", "COMPLETE", "TERMINATE", "KEYPRESS", "SCROLL"{{', "NEW_TAB"' if show_new_tab_action else ""}}{{', "SWITCH_TAB"' if show_switch_tab_action else ""}}{{', "CLOSE_PAGE"' if show_close_page_action else ""}}. "CLICK" is an element you'd like to click. "HOVER" is used to move the mouse over an element without clicking, particularly when revealing hover-only menus or buttons before clicking, or when the UI hints that a control (like a CTA button) only appears after hovering a card, tile, or model name. "INPUT_TEXT" is an element you'd like to input text into. "UPLOAD_FILE" is an element you'd like to upload a file into. "SELECT_OPTION" is an element you'd like to select an option from. "WAIT" action should be used if there are no actions to take and there is some indication on screen that waiting could yield more actions. "WAIT" should not be used if there are actions to take. "SOLVE_CAPTCHA" should be used if there's a visible captcha to solve on the screen. Captcha tokens expire quickly (~2 minutes), so fill all form fields first, then SOLVE_CAPTCHA immediately before the final submit or protected click — do not place SOLVE_CAPTCHA before a long form-fill sequence. "COMPLETE" is used when the {{"complete criterion has been met" if complete_criterion else "user goal has been achieved"}} AND if there's any data extraction goal, you should be able to get data from the page. Never return a COMPLETE action unless the {{ "complete criterion is met" if complete_criterion else "user goal is achieved" }}. "TERMINATE" is used to terminate the whole task with a failure when it doesn't seem like the user goal can be achieved. Do not use "TERMINATE" if waiting could lead the user towards the goal. Only return "TERMINATE" if you are on a page where the user goal cannot be achieved. All other actions are ignored when "TERMINATE" is returned. "KEYPRESS" is used to press a keyboard key when no clickable button or element achieves the same result. Only use KEYPRESS when pressing a key is the sole way to proceed (e.g., pressing Enter to submit a search with no search button, or Escape to close a modal with no close button). KEYPRESS does not require an element id. Requires the "key" field. "SCROLL" is used to scroll within a specific scrollable container on the page (not the page itself). Only use SCROLL when a required action is blocked because the target element is hidden, disabled, or unreachable until the container is scrolled (e.g., an "Agree" button that only becomes enabled after scrolling to the bottom of a terms and conditions box). Do not use SCROLL for general page navigation. Provide the element id of an interactable element within or near the scrollable container. Requires the "direction" field. SCROLL does not require a "text", "option", or "file_url" field.{{' "CLOSE_PAGE" is used to close the current tab and return to a previous tab. Use it when the page instructs you to close it or return to the original page, or when the user goal explicitly requires closing this tab. Do not use CLOSE_PAGE simply because the goal cannot be achieved — use TERMINATE for that.' if show_close_page_action else ''}}{{' "NEW_TAB" opens a new browser tab at a given URL and makes it the active tab, keeping existing tabs open. Use it to open a page in a separate tab while keeping the current tab open (for example, to compare two pages). NEW_TAB requires the "url" field set to a fully-qualified http/https URL. Do not use NEW_TAB to follow a normal link on the page when a clickable element is available. NEW_TAB does not require an element id.' if show_new_tab_action else ''}}{{' "SWITCH_TAB" makes another already-open tab the active tab so you can see and act on it. SWITCH_TAB requires the "tab_index" field set to the number shown for the target tab in the open browser tabs list. Use it to return to an earlier tab without closing the current one. SWITCH_TAB does not require an element id.' if show_switch_tab_action else ''}}- "id": str, // The id of the element to take action on. The id has to be one from the elements list. For target-less actions (SOLVE_CAPTCHA, WAIT, COMPLETE, TERMINATE, KEYPRESS), set this to null.+ "action_type": str, // It's a string enum: "CLICK", "HOVER", "INPUT_TEXT", "UPLOAD_FILE", "SELECT_OPTION", "WAIT", "SOLVE_CAPTCHA", "COMPLETE", "TERMINATE", "KEYPRESS", "SCROLL"{{', "GOTO_URL", "RELOAD_PAGE"' if enable_new_planner_actions else ""}}{{', "EXTRACT_INFORMATION"' if enable_new_planner_actions and data_extraction_goal else ""}}{{', "NEW_TAB"' if show_new_tab_action else ""}}{{', "SWITCH_TAB"' if show_switch_tab_action else ""}}{{', "CLOSE_PAGE"' if show_close_page_action else ""}}. "CLICK" is an element you'd like to click. "HOVER" is used to move the mouse over an element without clicking, particularly when revealing hover-only menus or buttons before clicking, or when the UI hints that a control (like a CTA button) only appears after hovering a card, tile, or model name. "INPUT_TEXT" is an element you'd like to input text into. "UPLOAD_FILE" is an element you'd like to upload a file into. "SELECT_OPTION" is an element you'd like to select an option from. "WAIT" action should be used if there are no actions to take and there is some indication on screen that waiting could yield more actions. "WAIT" should not be used if there are actions to take. "SOLVE_CAPTCHA" should be used if there's a visible captcha to solve on the screen. Captcha tokens expire quickly (~2 minutes), so fill all form fields first, then SOLVE_CAPTCHA immediately before the final submit or protected click — do not place SOLVE_CAPTCHA before a long form-fill sequence. "COMPLETE" is used when the {{"complete criterion has been met" if complete_criterion else "user goal has been achieved"}} AND if there's any data extraction goal, you should be able to get data from the page. Never return a COMPLETE action unless the {{ "complete criterion is met" if complete_criterion else "user goal is achieved" }}. "TERMINATE" is used to terminate the whole task with a failure when it doesn't seem like the user goal can be achieved. Do not use "TERMINATE" if waiting could lead the user towards the goal. Only return "TERMINATE" if you are on a page where the user goal cannot be achieved. All other actions are ignored when "TERMINATE" is returned. "KEYPRESS" is used to press a keyboard key when no clickable button or element achieves the same result. Only use KEYPRESS when pressing a key is the sole way to proceed (e.g., pressing Enter to submit a search with no search button, or Escape to close a modal with no close button). KEYPRESS does not require an element id. Requires the "key" field. "SCROLL" is used to scroll within a specific scrollable container on the page (not the page itself). Only use SCROLL when a required action is blocked because the target element is hidden, disabled, or unreachable until the container is scrolled (e.g., an "Agree" button that only becomes enabled after scrolling to the bottom of a terms and conditions box). Do not use SCROLL for general page navigation. Provide the element id of an interactable element within or near the scrollable container. Requires the "direction" field. SCROLL does not require a "text", "option", or "file_url" field.{% if enable_new_planner_actions %} "GOTO_URL" is used to navigate the current tab directly to a fully-qualified http/https URL. Only use GOTO_URL when the user goal requires direct navigation and the exact target URL comes from the user goal, the user details, the page content, or the action history. Do not use GOTO_URL to follow a normal link on the page when a clickable element is available — use CLICK on that element instead. Never invent, guess, or construct website-specific URLs or query parameters that are not explicitly available to you. If the URL of the page you're on right now already matches the target URL (ignoring a trailing slash), do not use GOTO_URL to reload the page. Element ids from the current page become invalid after navigation, so GOTO_URL must be the only action or the last action in the array. GOTO_URL is target-less and requires the "url" field. "RELOAD_PAGE" reloads the current page. Only use RELOAD_PAGE when the page itself is in a broken or stale state that a refresh would fix — content failed to load, a spinner or loading state is stuck, the DOM looks empty or only partially rendered, or the page shows a transient error. Do not use RELOAD_PAGE for normal navigation, and do not use it to retry an action that simply didn't achieve the goal — only when the page itself appears broken. RELOAD_PAGE is target-less and takes no extra fields.{% endif %}{{' "EXTRACT_INFORMATION" is used to extract the information described in the user data extraction goal from the current page. Only use EXTRACT_INFORMATION when the current page already contains the data requested in the data extraction goal and the page state is ready for extraction (fully loaded, filters applied, correct tab or section visible). Extraction runs against the current page state, so never place EXTRACT_INFORMATION after page-changing actions in the same array. If the user goal is also achieved, return COMPLETE right after EXTRACT_INFORMATION in the same array. EXTRACT_INFORMATION is target-less.' if enable_new_planner_actions and data_extraction_goal else ''}}{{' "NEW_TAB" opens a new browser tab at a given URL and makes it the active tab, keeping existing tabs open. Use it to open a page in a separate tab while keeping the current tab open (for example, to compare two pages). NEW_TAB requires the "url" field set to a fully-qualified http/https URL. Do not use NEW_TAB to follow a normal link on the page when a clickable element is available. NEW_TAB does not require an element id.' if show_new_tab_action else ''}}{{' "SWITCH_TAB" makes another already-open tab the active tab so you can see and act on it. SWITCH_TAB requires the "tab_index" field set to the number shown for the target tab in the open browser tabs list. Use it to return to an earlier tab without closing the current one. SWITCH_TAB does not require an element id.' if show_switch_tab_action else ''}}{{' "CLOSE_PAGE" is used to close the current tab and return to a previous tab. Use it when the page instructs you to close it or return to the original page, or when the user goal explicitly requires closing this tab. Do not use CLOSE_PAGE simply because the goal cannot be achieved — use TERMINATE for that.' if show_close_page_action else ''}}+ "id": str, // The id of the element to take action on. The id has to be one from the elements list. For target-less actions (SOLVE_CAPTCHA, WAIT, COMPLETE, TERMINATE, KEYPRESS{{', GOTO_URL, RELOAD_PAGE' if enable_new_planner_actions else ''}}{{', EXTRACT_INFORMATION' if enable_new_planner_actions and data_extraction_goal else ''}}), set this to null."captcha_type": str, // The type of captcha for SOLVE_CAPTCHA action only. null if not SOLVE_CAPTCHA action. It's a string enum: "TEXT_CAPTCHA", "RECAPTCHA", "HCAPTCHA", "MTCAPTCHA", "FUNCAPTCHA", "CLOUDFLARE", "OTHER"."text": str, // Text for INPUT_TEXT action only"key": str, // The keyboard key to press for KEYPRESS action only. Allowed values: "Enter", "Tab", "Escape", "ArrowDown", "ArrowUp". For "0"-"9" and "a"-"z", use KEYPRESS only when no suitable element is available for INPUT_TEXT. null if not KEYPRESS action."repeat": int, // For KEYPRESS only: how many times to press the key in rapid succession without re-evaluating the page between presses. Use this when navigating transient menus (e.g., ArrowDown 3 times to reach an item). Defaults to 1. null if not KEYPRESS action.- "direction": str, // The direction to scroll for SCROLL action only. Allowed values: "up", "down". null if not SCROLL action.{{'\n "url": str, // The fully-qualified http/https URL to open for NEW_TAB action only (required for NEW_TAB). null if not NEW_TAB action.' if show_new_tab_action else ''}}{{'\n "tab_index": int, // The tab number to switch to for SWITCH_TAB action only, taken from the open browser tabs list (required for SWITCH_TAB). null if not SWITCH_TAB action.' if show_switch_tab_action else ''}}- "file_url": str, // The url of the file to upload if applicable. This field must be present for UPLOAD_FILE but can also be present for CLICK only if the click is to upload the file. It should be null otherwise.+ "direction": str, // The direction to scroll for SCROLL action only. Allowed values: "up", "down". null if not SCROLL action.+{% if enable_new_planner_actions and show_new_tab_action %} "url": str, // The fully-qualified http/https URL. For GOTO_URL, navigate the current tab to this URL; for NEW_TAB, open this URL in a new tab. null if not a navigation action.+{% elif enable_new_planner_actions %} "url": str, // The fully-qualified http/https URL to navigate to for GOTO_URL action only. null if not GOTO_URL action.+{% elif show_new_tab_action %} "url": str, // The fully-qualified http/https URL to open for NEW_TAB action only (required for NEW_TAB). null if not NEW_TAB action.+{% endif %}{% if show_switch_tab_action %} "tab_index": int, // The tab number to switch to for SWITCH_TAB action only, taken from the open browser tabs list (required for SWITCH_TAB). null if not SWITCH_TAB action.+{% endif %} "file_url": str, // The url of the file to upload if applicable. This field must be present for UPLOAD_FILE but can also be present for CLICK only if the click is to upload the file. It should be null otherwise."double_click": bool, // For CLICK action only. True only when the element requires a double-click to activate (e.g., opening a file in a file manager, entering edit mode in a spreadsheet cell, or expanding a tree node). Defaults to false for normal clicks. Do not use double-click for regular buttons, links, form elements, clickable grid rows, icons, or dashboard cards."download": bool, // Can only be true for CLICK or SELECT_OPTION actions. If true, the browser will trigger a download by clicking the element. If false, the browser will click the element without triggering a download."option": { // The option to select for SELECT_OPTION action only. null if not SELECT_OPTION actiondiff --git a/skyvern/forge/prompts/skyvern/extract-action.j2 b/skyvern/forge/prompts/skyvern/extract-action.j2index 0c681eb0d..525fd6794 100644--- a/skyvern/forge/prompts/skyvern/extract-action.j2+++ b/skyvern/forge/prompts/skyvern/extract-action.j2@@ -21,14 +21,18 @@ Reply in JSON format with the following keys:"user_detail_query": str, // Think of this value as a Jeopardy question and the intention behind the action. Ask the user for the details you need for executing this action. IMPORTANT: This question must be user information agnostic and must NOT contain specific user data (like names, IDs, specific values, etc.). Ask what information is needed generically. Ask the question even if the details are disclosed in user goal or user details. If it's a text field, ask for the text. If it's a file upload, ask for the file. If it's a dropdown, ask for the relevant information. If you are clicking on something specific, ask about what the intention is behind the click and what to click on. If you're downloading a file and you have multiple options, ask the user which one to download. Examples are: "What product ID should I input into the search bar?", "What file should I upload?", "What is the previous insurance provider of the user?", "Which invoice should I download?", "Does the user have any pets?", "Which member should I take action on?". NEVER include specific user data in this question - keep it generic so it can be answered with different user contexts."user_detail_answer": str, // The answer to the `user_detail_query`. The source of this answer can be user goal or user details. This answer CAN contain specific user data."confidence_float": float, // The confidence of the action. Pick a number between 0.0 and 1.0. 0.0 means no confidence, 1.0 means full confidence- "action_type": str, // It's a string enum: "CLICK", "HOVER", "INPUT_TEXT", "UPLOAD_FILE", "SELECT_OPTION", "WAIT", "SOLVE_CAPTCHA", "COMPLETE", "TERMINATE", "KEYPRESS", "SCROLL"{{', "NEW_TAB"' if show_new_tab_action else ""}}{{', "SWITCH_TAB"' if show_switch_tab_action else ""}}{{', "CLOSE_PAGE"' if show_close_page_action else ""}}. "CLICK" is an element you'd like to click. "HOVER" is used to move the mouse over an element without clicking, particularly when revealing hover-only menus or buttons before clicking, or when the UI hints that a control (like a CTA button) only appears after hovering a card, tile, or model name. "INPUT_TEXT" is an element you'd like to input text into. "UPLOAD_FILE" is an element you'd like to upload a file into. "SELECT_OPTION" is an element you'd like to select an option from. "WAIT" action should be used if there are no actions to take and there is some indication on screen that waiting could yield more actions. "WAIT" should not be used if there are actions to take. "SOLVE_CAPTCHA" should be used if there's a visible captcha to solve on the screen. Captcha tokens expire quickly (~2 minutes), so fill all form fields first, then SOLVE_CAPTCHA immediately before the final submit or protected click — do not place SOLVE_CAPTCHA before a long form-fill sequence. "COMPLETE" is used when the {{"complete criterion has been met" if complete_criterion else "user goal has been achieved"}} AND if there's any data extraction goal, you should be able to get data from the page. Never return a COMPLETE action unless the {{ "complete criterion is met" if complete_criterion else "user goal is achieved" }}. "TERMINATE" is used to terminate the whole task with a failure when it doesn't seem like the user goal can be achieved. Do not use "TERMINATE" if waiting could lead the user towards the goal. Only return "TERMINATE" if you are on a page where the user goal cannot be achieved. All other actions are ignored when "TERMINATE" is returned. "KEYPRESS" is used to press a keyboard key when no clickable button or element achieves the same result. Only use KEYPRESS when pressing a key is the sole way to proceed (e.g., pressing Enter to submit a search with no search button, or Escape to close a modal with no close button). KEYPRESS does not require an element id. Requires the "key" field. "SCROLL" is used to scroll within a specific scrollable container on the page (not the page itself). Only use SCROLL when a required action is blocked because the target element is hidden, disabled, or unreachable until the container is scrolled (e.g., an "Agree" button that only becomes enabled after scrolling to the bottom of a terms and conditions box). Do not use SCROLL for general page navigation. Provide the element id of an interactable element within or near the scrollable container. Requires the "direction" field. SCROLL does not require a "text", "option", or "file_url" field.{{' "CLOSE_PAGE" is used to close the current tab and return to a previous tab. Use it when the page instructs you to close it or return to the original page, or when the user goal explicitly requires closing this tab. Do not use CLOSE_PAGE simply because the goal cannot be achieved — use TERMINATE for that.' if show_close_page_action else ''}}{{' "NEW_TAB" opens a new browser tab at a given URL and makes it the active tab, keeping existing tabs open. Use it to open a page in a separate tab while keeping the current tab open (for example, to compare two pages). NEW_TAB requires the "url" field set to a fully-qualified http/https URL. Do not use NEW_TAB to follow a normal link on the page when a clickable element is available. NEW_TAB does not require an element id.' if show_new_tab_action else ''}}{{' "SWITCH_TAB" makes another already-open tab the active tab so you can see and act on it. SWITCH_TAB requires the "tab_index" field set to the number shown for the target tab in the open browser tabs list. Use it to return to an earlier tab without closing the current one. SWITCH_TAB does not require an element id.' if show_switch_tab_action else ''}}- "id": str, // The id of the element to take action on. The id has to be one from the elements list. For target-less actions (SOLVE_CAPTCHA, WAIT, COMPLETE, TERMINATE, KEYPRESS), set this to null.+ "action_type": str, // It's a string enum: "CLICK", "HOVER", "INPUT_TEXT", "UPLOAD_FILE", "SELECT_OPTION", "WAIT", "SOLVE_CAPTCHA", "COMPLETE", "TERMINATE", "KEYPRESS", "SCROLL"{{', "GOTO_URL", "RELOAD_PAGE"' if enable_new_planner_actions else ""}}{{', "EXTRACT_INFORMATION"' if enable_new_planner_actions and data_extraction_goal else ""}}{{', "NEW_TAB"' if show_new_tab_action else ""}}{{', "SWITCH_TAB"' if show_switch_tab_action else ""}}{{', "CLOSE_PAGE"' if show_close_page_action else ""}}. "CLICK" is an element you'd like to click. "HOVER" is used to move the mouse over an element without clicking, particularly when revealing hover-only menus or buttons before clicking, or when the UI hints that a control (like a CTA button) only appears after hovering a card, tile, or model name. "INPUT_TEXT" is an element you'd like to input text into. "UPLOAD_FILE" is an element you'd like to upload a file into. "SELECT_OPTION" is an element you'd like to select an option from. "WAIT" action should be used if there are no actions to take and there is some indication on screen that waiting could yield more actions. "WAIT" should not be used if there are actions to take. "SOLVE_CAPTCHA" should be used if there's a visible captcha to solve on the screen. Captcha tokens expire quickly (~2 minutes), so fill all form fields first, then SOLVE_CAPTCHA immediately before the final submit or protected click — do not place SOLVE_CAPTCHA before a long form-fill sequence. "COMPLETE" is used when the {{"complete criterion has been met" if complete_criterion else "user goal has been achieved"}} AND if there's any data extraction goal, you should be able to get data from the page. Never return a COMPLETE action unless the {{ "complete criterion is met" if complete_criterion else "user goal is achieved" }}. "TERMINATE" is used to terminate the whole task with a failure when it doesn't seem like the user goal can be achieved. Do not use "TERMINATE" if waiting could lead the user towards the goal. Only return "TERMINATE" if you are on a page where the user goal cannot be achieved. All other actions are ignored when "TERMINATE" is returned. "KEYPRESS" is used to press a keyboard key when no clickable button or element achieves the same result. Only use KEYPRESS when pressing a key is the sole way to proceed (e.g., pressing Enter to submit a search with no search button, or Escape to close a modal with no close button). KEYPRESS does not require an element id. Requires the "key" field. "SCROLL" is used to scroll within a specific scrollable container on the page (not the page itself). Only use SCROLL when a required action is blocked because the target element is hidden, disabled, or unreachable until the container is scrolled (e.g., an "Agree" button that only becomes enabled after scrolling to the bottom of a terms and conditions box). Do not use SCROLL for general page navigation. Provide the element id of an interactable element within or near the scrollable container. Requires the "direction" field. SCROLL does not require a "text", "option", or "file_url" field.{% if enable_new_planner_actions %} "GOTO_URL" is used to navigate the current tab directly to a fully-qualified http/https URL. Only use GOTO_URL when the user goal requires direct navigation and the exact target URL comes from the user goal, the user details, the page content, or the action history. Do not use GOTO_URL to follow a normal link on the page when a clickable element is available — use CLICK on that element instead. Never invent, guess, or construct website-specific URLs or query parameters that are not explicitly available to you. If the URL of the page you're on right now already matches the target URL (ignoring a trailing slash), do not use GOTO_URL to reload the page. Element ids from the current page become invalid after navigation, so GOTO_URL must be the only action or the last action in the array. GOTO_URL is target-less and requires the "url" field. "RELOAD_PAGE" reloads the current page. Only use RELOAD_PAGE when the page itself is in a broken or stale state that a refresh would fix — content failed to load, a spinner or loading state is stuck, the DOM looks empty or only partially rendered, or the page shows a transient error. Do not use RELOAD_PAGE for normal navigation, and do not use it to retry an action that simply didn't achieve the goal — only when the page itself appears broken. RELOAD_PAGE is target-less and takes no extra fields.{% endif %}{{' "EXTRACT_INFORMATION" is used to extract the information described in the user data extraction goal from the current page. Only use EXTRACT_INFORMATION when the current page already contains the data requested in the data extraction goal and the page state is ready for extraction (fully loaded, filters applied, correct tab or section visible). Extraction runs against the current page state, so never place EXTRACT_INFORMATION after page-changing actions in the same array. If the user goal is also achieved, return COMPLETE right after EXTRACT_INFORMATION in the same array. EXTRACT_INFORMATION is target-less.' if enable_new_planner_actions and data_extraction_goal else ''}}{{' "NEW_TAB" opens a new browser tab at a given URL and makes it the active tab, keeping existing tabs open. Use it to open a page in a separate tab while keeping the current tab open (for example, to compare two pages). NEW_TAB requires the "url" field set to a fully-qualified http/https URL. Do not use NEW_TAB to follow a normal link on the page when a clickable element is available. NEW_TAB does not require an element id.' if show_new_tab_action else ''}}{{' "SWITCH_TAB" makes another already-open tab the active tab so you can see and act on it. SWITCH_TAB requires the "tab_index" field set to the number shown for the target tab in the open browser tabs list. Use it to return to an earlier tab without closing the current one. SWITCH_TAB does not require an element id.' if show_switch_tab_action else ''}}{{' "CLOSE_PAGE" is used to close the current tab and return to a previous tab. Use it when the page instructs you to close it or return to the original page, or when the user goal explicitly requires closing this tab. Do not use CLOSE_PAGE simply because the goal cannot be achieved — use TERMINATE for that.' if show_close_page_action else ''}}+ "id": str, // The id of the element to take action on. The id has to be one from the elements list. For target-less actions (SOLVE_CAPTCHA, WAIT, COMPLETE, TERMINATE, KEYPRESS{{', GOTO_URL, RELOAD_PAGE' if enable_new_planner_actions else ''}}{{', EXTRACT_INFORMATION' if enable_new_planner_actions and data_extraction_goal else ''}}), set this to null."captcha_type": str, // The type of captcha for SOLVE_CAPTCHA action only. null if not SOLVE_CAPTCHA action. It's a string enum: "TEXT_CAPTCHA", "RECAPTCHA", "HCAPTCHA", "MTCAPTCHA", "FUNCAPTCHA", "CLOUDFLARE", "OTHER"."text": str, // Text for INPUT_TEXT action only"key": str, // The keyboard key to press for KEYPRESS action only. Allowed values: "Enter", "Tab", "Escape", "ArrowDown", "ArrowUp". For "0"-"9" and "a"-"z", use KEYPRESS only when no suitable element is available for INPUT_TEXT. null if not KEYPRESS action."repeat": int, // For KEYPRESS only: how many times to press the key in rapid succession without re-evaluating the page between presses. Use this when navigating transient menus (e.g., ArrowDown 3 times to reach an item). Defaults to 1. null if not KEYPRESS action.- "direction": str, // The direction to scroll for SCROLL action only. Allowed values: "up", "down". null if not SCROLL action.{{'\n "url": str, // The fully-qualified http/https URL to open for NEW_TAB action only (required for NEW_TAB). null if not NEW_TAB action.' if show_new_tab_action else ''}}{{'\n "tab_index": int, // The tab number to switch to for SWITCH_TAB action only, taken from the open browser tabs list (required for SWITCH_TAB). null if not SWITCH_TAB action.' if show_switch_tab_action else ''}}- "file_url": str, // The url of the file to upload if applicable. This field must be present for UPLOAD_FILE but can also be present for CLICK only if the click is to upload the file. It should be null otherwise.+ "direction": str, // The direction to scroll for SCROLL action only. Allowed values: "up", "down". null if not SCROLL action.+{% if enable_new_planner_actions and show_new_tab_action %} "url": str, // The fully-qualified http/https URL. For GOTO_URL, navigate the current tab to this URL; for NEW_TAB, open this URL in a new tab. null if not a navigation action.+{% elif enable_new_planner_actions %} "url": str, // The fully-qualified http/https URL to navigate to for GOTO_URL action only. null if not GOTO_URL action.+{% elif show_new_tab_action %} "url": str, // The fully-qualified http/https URL to open for NEW_TAB action only (required for NEW_TAB). null if not NEW_TAB action.+{% endif %}{% if show_switch_tab_action %} "tab_index": int, // The tab number to switch to for SWITCH_TAB action only, taken from the open browser tabs list (required for SWITCH_TAB). null if not SWITCH_TAB action.+{% endif %} "file_url": str, // The url of the file to upload if applicable. This field must be present for UPLOAD_FILE but can also be present for CLICK only if the click is to upload the file. It should be null otherwise."double_click": bool, // For CLICK action only. True only when the element requires a double-click to activate (e.g., opening a file in a file manager, entering edit mode in a spreadsheet cell, or expanding a tree node). Defaults to false for normal clicks. Do not use double-click for regular buttons, links, form elements, clickable grid rows, icons, or dashboard cards."download": bool, // Can only be true for CLICK or SELECT_OPTION actions. If true, the browser will trigger a download by clicking the element. If false, the browser will click the element without triggering a download."option": { // The option to select for SELECT_OPTION action only. null if not SELECT_OPTION actiondiff --git a/skyvern/forge/sdk/models.py b/skyvern/forge/sdk/models.pyindex 73d5c703d..37d3671de 100644--- a/skyvern/forge/sdk/models.py+++ b/skyvern/forge/sdk/models.py@@ -111,7 +111,7 @@ class Step(BaseModel):if is_last is False:raise ValueError(f"cant_set_is_last_to_false({self.step_id})")- def is_goal_achieved(self) -> bool:+ def is_goal_achieved(self, has_navigation_goal: bool = False) -> bool:# TODO: now we also consider a step has achieved the goal if the task doesn't have a navigation goal# and the data extraction is successful@@ -129,6 +129,17 @@ class Step(BaseModel):if last_action.action_type not in [ActionType.COMPLETE, ActionType.EXTRACT]:return False+ if last_action.action_type == ActionType.EXTRACT and has_navigation_goal:+ # A planner-emitted mid-task EXTRACT must not complete a task that still has a+ # navigation goal; only accept it when a successful COMPLETE exists in the step+ # (the agent appends its own EXTRACT right after a verified COMPLETE).+ step_has_successful_complete = any(+ action.action_type == ActionType.COMPLETE and any(result.success for result in results)+ for action, results in self.output.actions_and_results+ )+ if not step_has_successful_complete:+ return False+return any(action_result.success for action_result in last_action_results)def is_success(self) -> bool:diff --git a/skyvern/webeye/actions/handler.py b/skyvern/webeye/actions/handler.pyindex a1d7f665a..bf7010cdb 100644--- a/skyvern/webeye/actions/handler.py+++ b/skyvern/webeye/actions/handler.py@@ -3265,7 +3265,11 @@ async def handle_goto_url_action(step: Step,) -> list[ActionResult]:await page.goto(action.url, timeout=settings.BROWSER_LOADING_TIMEOUT_MS)- return [ActionSuccess()]+ # Navigation invalidates the current scraped page's element ids; stop the batch so the+ # next step re-scrapes before any later actions run against the new DOM.+ result = ActionSuccess()+ result.skip_remaining_actions = True+ return [result]async def handle_go_back_action(@@ -3298,7 +3302,11 @@ async def handle_reload_page_action(step: Step,) -> list[ActionResult]:await page.reload(timeout=settings.BROWSER_LOADING_TIMEOUT_MS)- return [ActionSuccess()]+ # Reloading re-renders the DOM and invalidates the scraped page's element ids; stop the+ # batch so the next step re-scrapes before any later actions run.+ result = ActionSuccess()+ result.skip_remaining_actions = True+ return [result]@traced(name="skyvern.agent.action.close_page")diff --git a/skyvern/webeye/actions/parse_actions.py b/skyvern/webeye/actions/parse_actions.pyindex 1363e5b73..7268da164 100644--- a/skyvern/webeye/actions/parse_actions.py+++ b/skyvern/webeye/actions/parse_actions.py@@ -41,6 +41,7 @@ from skyvern.webeye.actions.actions import (CompleteAction,DownloadFileAction,DragAction,+ ExtractAction,GotoUrlAction,HoverAction,InputOrSelectContext,@@ -50,6 +51,7 @@ from skyvern.webeye.actions.actions import (MoveAction,NewTabAction,NullAction,+ ReloadPageAction,ScrollAction,SelectOption,SelectOptionAction,@@ -69,6 +71,7 @@ def parse_action(action: Dict[str, Any],scraped_page: ScrapedPage,data_extraction_goal: str | None = None,+ extracted_information_schema: dict[str, Any] | list | str | None = None,totp_code_required: bool = False,) -> Action:if "id" in action:@@ -114,6 +117,9 @@ def parse_action(# Backward compat: map PRESS_ENTER to KEYPRESS (old prompt used PRESS_ENTER)if action_type_str == "PRESS_ENTER":action_type_str = "KEYPRESS"+ # The prompt exposes EXTRACT as EXTRACT_INFORMATION; map it back to the internal enum name+ if action_type_str == "EXTRACT_INFORMATION":+ action_type_str = "EXTRACT"action_type = ActionType[action_type_str]if not action_type.is_web_action() and action_type != ActionType.SCROLL:@@ -256,6 +262,45 @@ def parse_action(if action_type == ActionType.CLOSE_PAGE:return ClosePageAction(**base_action_dict)+ if action_type == ActionType.EXTRACT:+ # EXTRACT is a global page action, not element-targeted+ base_action_dict["skyvern_element_hash"] = None+ base_action_dict["skyvern_element_data"] = None+ if not data_extraction_goal:+ LOG.warning("EXTRACT action returned without a data extraction goal, skipping action", raw_action=action)+ return NullAction(**base_action_dict)+ return ExtractAction(+ **base_action_dict,+ data_extraction_goal=data_extraction_goal,+ data_extraction_schema=extracted_information_schema,+ )++ if action_type == ActionType.GOTO_URL:+ # GOTO_URL is a global navigation action, not element-targeted+ base_action_dict["skyvern_element_hash"] = None+ base_action_dict["skyvern_element_data"] = None+ url = action.get("url")+ if not url or not isinstance(url, str):+ LOG.warning("GOTO_URL action returned without a url, skipping action", raw_action=action)+ return NullAction(**base_action_dict)+ try:+ validated_url = prepend_scheme_and_validate_url(url.strip())+ except InvalidUrl:+ LOG.warning("GOTO_URL action returned with an invalid url, skipping action", url=url)+ return NullAction(**base_action_dict)+ # LLM-generated navigation targets can be steered by page content, so block+ # private/loopback/link-local hosts the same way the task URL boundary does.+ host = urlparse(validated_url).hostname+ if not host or is_blocked_host(host):+ LOG.warning("GOTO_URL action targets a blocked host, skipping action", url=validated_url)+ return NullAction(**base_action_dict)+ return GotoUrlAction(**base_action_dict, url=validated_url)++ if action_type == ActionType.RELOAD_PAGE:+ base_action_dict["skyvern_element_hash"] = None+ base_action_dict["skyvern_element_data"] = None+ return ReloadPageAction(**base_action_dict)+if action_type == ActionType.NEW_TAB:url = action.get("url")if not url or not isinstance(url, str):@@ -303,6 +348,7 @@ def parse_actions(action=action,scraped_page=scraped_page,data_extraction_goal=task.data_extraction_goal,+ extracted_information_schema=task.extracted_information_schema,totp_code_required=totp_code_required,)action_instance.organization_id = task.organization_iddiff --git a/tests/unit/test_actions.py b/tests/unit/test_actions.pyindex 9b331afd6..7234499f5 100644--- a/tests/unit/test_actions.py+++ b/tests/unit/test_actions.py@@ -20,10 +20,13 @@ from skyvern.webeye.actions.action_types import ActionTypefrom skyvern.webeye.actions.actions import (Action,ClickAction,+ ExtractAction,+ GotoUrlAction,InputTextAction,KeypressAction,NewTabAction,NullAction,+ ReloadPageAction,SelectOptionAction,SwitchTabAction,WebAction,@@ -488,6 +491,115 @@ def test_parse_click_download_field(download_value: bool | None) -> None:assert action.download is expected[email protected]("action_type", ["EXTRACT_INFORMATION", "EXTRACT", "extract_information"])+def test_parse_extract_information_with_extraction_goal(action_type: str) -> None:+ schema = {"type": "object", "properties": {"price": {"type": "string"}}}+ action = parse_action(+ action={"action_type": action_type, "id": None, "reasoning": "test"},+ scraped_page=_mock_scraped_page(),+ data_extraction_goal="extract the price",+ extracted_information_schema=schema,+ )+ assert isinstance(action, ExtractAction)+ assert action.data_extraction_goal == "extract the price"+ assert action.data_extraction_schema == schema+ assert action.element_id is None+ assert action.skyvern_element_hash is None+ assert action.skyvern_element_data is None+++def test_parse_extract_information_clears_hallucinated_element_id() -> None:+ action = parse_action(+ action={"action_type": "EXTRACT_INFORMATION", "id": "42", "reasoning": "test"},+ scraped_page=_mock_scraped_page(),+ data_extraction_goal="extract the price",+ )+ assert isinstance(action, ExtractAction)+ assert action.element_id is None+++def test_parse_extract_information_without_extraction_goal_returns_null_action() -> None:+ action = parse_action(+ action={"action_type": "EXTRACT_INFORMATION", "id": None, "reasoning": "test"},+ scraped_page=_mock_scraped_page(),+ )+ assert isinstance(action, NullAction)+++def test_parse_goto_url_valid_url() -> None:+ action = parse_action(+ action={"action_type": "GOTO_URL", "id": None, "url": "https://example.com/a", "reasoning": "test"},+ scraped_page=_mock_scraped_page(),+ )+ assert isinstance(action, GotoUrlAction)+ assert action.url == "https://example.com/a"+ assert action.element_id is None+ assert action.skyvern_element_hash is None+ assert action.skyvern_element_data is None+ assert action.is_magic_link is False+++def test_parse_goto_url_prepends_https_scheme() -> None:+ action = parse_action(+ action={"action_type": "GOTO_URL", "id": None, "url": "example.com/a", "reasoning": "test"},+ scraped_page=_mock_scraped_page(),+ )+ assert isinstance(action, GotoUrlAction)+ assert action.url == "https://example.com/a"+++def test_parse_goto_url_clears_hallucinated_element_id() -> None:+ action = parse_action(+ action={"action_type": "GOTO_URL", "id": "7", "url": "https://example.com", "reasoning": "test"},+ scraped_page=_mock_scraped_page(),+ )+ assert isinstance(action, GotoUrlAction)+ assert action.element_id is None++[email protected]("url", [None, "", "ftp://example.com", "not a url"])+def test_parse_goto_url_invalid_or_missing_url_returns_null_action(url: str | None) -> None:+ action = parse_action(+ action={"action_type": "GOTO_URL", "id": None, "url": url, "reasoning": "test"},+ scraped_page=_mock_scraped_page(),+ )+ assert isinstance(action, NullAction)+++def test_parse_goto_url_without_url_key_returns_null_action() -> None:+ action = parse_action(+ action={"action_type": "GOTO_URL", "id": None, "reasoning": "test"},+ scraped_page=_mock_scraped_page(),+ )+ assert isinstance(action, NullAction)+++ "url",+ [+ "http://localhost:8000/admin",+ "http://127.0.0.1/latest",+ "http://169.254.169.254/latest/meta-data",+ "http://10.0.0.5/internal",+ ],+)+def test_parse_goto_url_blocked_host_returns_null_action(url: str) -> None:+ action = parse_action(+ action={"action_type": "GOTO_URL", "id": None, "url": url, "reasoning": "test"},+ scraped_page=_mock_scraped_page(),+ )+ assert isinstance(action, NullAction)+++def test_parse_reload_page() -> None:+ action = parse_action(+ action={"action_type": "RELOAD_PAGE", "id": None, "reasoning": "test"},+ scraped_page=_mock_scraped_page(),+ )+ assert isinstance(action, ReloadPageAction)+ assert action.element_id is None++def test_parse_new_tab_action_with_url() -> None:action = parse_action(action={"action_type": "NEW_TAB", "url": "https://example.test/page", "reasoning": "open a separate tab"},diff --git a/tests/unit/test_extract_action_prompt.py b/tests/unit/test_extract_action_prompt.pynew file mode 100644index 000000000..82db6f8a2--- /dev/null+++ b/tests/unit/test_extract_action_prompt.py@@ -0,0 +1,84 @@+"""Contract tests for the flag-gated planner actions (GOTO_URL / RELOAD_PAGE / EXTRACT_INFORMATION)."""++from __future__ import annotations++from typing import Any++import pytest++from skyvern.forge.sdk.prompting import PromptEngine++_EXTRACT_ACTION_KWARGS: dict[str, Any] = {+ "navigation_goal": "test goal",+ "navigation_payload_str": "{}",+ "starting_url": "https://example.com",+ "current_url": "https://example.com",+ "data_extraction_goal": None,+ "action_history": "[]",+ "error_code_mapping_str": None,+ "local_datetime": "2025-01-01T00:00:00",+ "verification_code_check": False,+ "complete_criterion": None,+ "terminate_criterion": None,+ "show_close_page_action": False,+ "open_tabs_context": None,+ "recent_dialog_messages_str": None,+ "llm_screenshots_enabled": True,+ "enriched_tree_enabled": False,+ "elements": "<html></html>",+}++_NEW_ACTIONS = ("GOTO_URL", "RELOAD_PAGE", "EXTRACT_INFORMATION")+++def prompt_engine() -> PromptEngine:+ return PromptEngine(model="skyvern")++[email protected]("template", ["extract-action", "extract-action-static"])+def test_new_planner_actions_absent_when_flag_off(prompt_engine: PromptEngine, template: str) -> None:+ # Flag defaults off (kwarg omitted -> Jinja Undefined -> falsy). Even with an extraction goal,+ # none of the new actions should surface -> the control cohort matches the pre-PR prompt.+ rendered = prompt_engine.load_prompt(+ template, **{**_EXTRACT_ACTION_KWARGS, "data_extraction_goal": "extract the price"}+ )+ for action in _NEW_ACTIONS:+ assert action not in rendered+ assert '"url": str' not in rendered++[email protected]("template", ["extract-action", "extract-action-static"])+def test_goto_url_and_reload_in_schema_when_flag_on(prompt_engine: PromptEngine, template: str) -> None:+ rendered = prompt_engine.load_prompt(template, **{**_EXTRACT_ACTION_KWARGS, "enable_new_planner_actions": True})+ assert '"GOTO_URL"' in rendered+ assert '"RELOAD_PAGE"' in rendered+ assert '"url": str' in rendered+ assert "TERMINATE, KEYPRESS, GOTO_URL, RELOAD_PAGE" in rendered+ # EXTRACT_INFORMATION still requires an extraction goal even when the flag is on.+ assert "EXTRACT_INFORMATION" not in rendered++[email protected]("template", ["extract-action", "extract-action-static"])+def test_extract_information_requires_flag_and_goal(prompt_engine: PromptEngine, template: str) -> None:+ without_goal = prompt_engine.load_prompt(template, **{**_EXTRACT_ACTION_KWARGS, "enable_new_planner_actions": True})+ assert "EXTRACT_INFORMATION" not in without_goal++ without_flag = prompt_engine.load_prompt(+ template, **{**_EXTRACT_ACTION_KWARGS, "data_extraction_goal": "extract the price"}+ )+ assert "EXTRACT_INFORMATION" not in without_flag++ with_both = prompt_engine.load_prompt(+ template,+ **{**_EXTRACT_ACTION_KWARGS, "enable_new_planner_actions": True, "data_extraction_goal": "extract the price"},+ )+ assert '"EXTRACT_INFORMATION"' in with_both+ assert "KEYPRESS, GOTO_URL, RELOAD_PAGE, EXTRACT_INFORMATION" in with_both+++def test_static_template_is_prefix_when_flag_on(prompt_engine: PromptEngine) -> None:+ kwargs = {**_EXTRACT_ACTION_KWARGS, "enable_new_planner_actions": True, "data_extraction_goal": "extract the price"}+ full = prompt_engine.load_prompt("extract-action", **kwargs)+ static = prompt_engine.load_prompt("extract-action-static", **kwargs)+ assert full.startswith(static.rstrip())diff --git a/tests/unit/test_navigation_action_handlers.py b/tests/unit/test_navigation_action_handlers.pynew file mode 100644index 000000000..532faa5c3--- /dev/null+++ b/tests/unit/test_navigation_action_handlers.py@@ -0,0 +1,45 @@+"""Tests for the GOTO_URL / RELOAD_PAGE action handlers."""++from unittest.mock import AsyncMock, MagicMock++import pytest++from skyvern.webeye.actions import actions+from skyvern.webeye.actions.handler import handle_goto_url_action, handle_reload_page_action+from skyvern.webeye.actions.responses import ActionSuccess+++def _task() -> MagicMock:+ task = MagicMock()+ task.task_id = "tsk_test"+ task.workflow_run_id = None+ return task+++async def test_goto_url_navigates_and_stops_batch() -> None:+ page = MagicMock()+ page.goto = AsyncMock()++ action = actions.GotoUrlAction(url="https://example.test/page")+ result = await handle_goto_url_action(action, page, MagicMock(), _task(), MagicMock())++ assert len(result) == 1+ assert isinstance(result[0], ActionSuccess)+ # Navigation invalidates pre-nav element ids, so later actions in the batch must not run.+ assert result[0].skip_remaining_actions is True+ page.goto.assert_awaited_once()+++async def test_reload_page_reloads_and_stops_batch() -> None:+ page = MagicMock()+ page.reload = AsyncMock()++ action = actions.ReloadPageAction()+ result = await handle_reload_page_action(action, page, MagicMock(), _task(), MagicMock())++ assert len(result) == 1+ assert isinstance(result[0], ActionSuccess)+ assert result[0].skip_remaining_actions is True+ page.reload.assert_awaited_once()diff --git a/tests/unit/test_step_goal_achieved.py b/tests/unit/test_step_goal_achieved.pynew file mode 100644index 000000000..1aae9662b--- /dev/null+++ b/tests/unit/test_step_goal_achieved.py@@ -0,0 +1,68 @@+"""Step.is_goal_achieved must not let a planner-emitted mid-task EXTRACT complete a navigation task."""++from datetime import datetime, timezone++from skyvern.forge.sdk.models import Step, StepStatus+from skyvern.schemas.steps import AgentStepOutput+from skyvern.webeye.actions.actions import Action, ClickAction, CompleteAction, ExtractAction+from skyvern.webeye.actions.responses import ActionFailure, ActionResult, ActionSuccess+++def _step(actions_and_results: list[tuple[Action, list[ActionResult]]]) -> Step:+ return Step(+ created_at=datetime(2025, 1, 1, tzinfo=timezone.utc),+ modified_at=datetime(2025, 1, 1, tzinfo=timezone.utc),+ task_id="tsk_1",+ step_id="stp_1",+ status=StepStatus.completed,+ output=AgentStepOutput(actions_and_results=actions_and_results),+ order=0,+ is_last=False,+ organization_id="o_1",+ )+++def test_trailing_complete_achieves_goal_with_navigation_goal() -> None:+ step = _step([(CompleteAction(reasoning="done"), [ActionSuccess()])])+ assert step.is_goal_achieved(has_navigation_goal=True) is True+ assert step.is_goal_achieved(has_navigation_goal=False) is True+++def test_trailing_extract_alone_does_not_achieve_goal_with_navigation_goal() -> None:+ step = _step([(ExtractAction(reasoning="extract"), [ActionSuccess(data={"price": "$1"})])])+ assert step.is_goal_achieved(has_navigation_goal=True) is False+++def test_trailing_extract_achieves_goal_without_navigation_goal() -> None:+ step = _step([(ExtractAction(reasoning="extract"), [ActionSuccess(data={"price": "$1"})])])+ assert step.is_goal_achieved(has_navigation_goal=False) is True+++def test_extract_appended_after_successful_complete_achieves_goal() -> None:+ step = _step(+ [+ (CompleteAction(reasoning="done"), [ActionSuccess()]),+ (ExtractAction(reasoning="extract"), [ActionSuccess(data={"price": "$1"})]),+ ]+ )+ assert step.is_goal_achieved(has_navigation_goal=True) is True+++def test_trailing_extract_after_failed_complete_does_not_achieve_goal() -> None:+ step = _step(+ [+ (CompleteAction(reasoning="done"), [ActionFailure(exception=Exception("not achieved"))]),+ (ExtractAction(reasoning="extract"), [ActionSuccess(data={"price": "$1"})]),+ ]+ )+ assert step.is_goal_achieved(has_navigation_goal=True) is False+++def test_trailing_web_action_does_not_achieve_goal() -> None:+ step = _step([(ClickAction(reasoning="click", element_id="1"), [ActionSuccess()])])+ assert step.is_goal_achieved(has_navigation_goal=False) is False+++def test_failed_trailing_extract_does_not_achieve_goal() -> None:+ step = _step([(ExtractAction(reasoning="extract"), [ActionFailure(exception=Exception("no data"))])])+ assert step.is_goal_achieved(has_navigation_goal=False) is False