Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
feat(task_v2): bias the planner toward loop tasks for repeated same-shape work (#6575)
Trevor Cheungd25ede611dc8
diff --git a/skyvern/forge/prompts/skyvern/task_v2.j2 b/skyvern/forge/prompts/skyvern/task_v2.j2index 4a7b6be0a..9de9f40b4 100644--- a/skyvern/forge/prompts/skyvern/task_v2.j2+++ b/skyvern/forge/prompts/skyvern/task_v2.j2@@ -3,9 +3,12 @@ You're to assist the user to achieve the user goal in the web, given the DOM eleYou have access to the following task types to take actions:- navigate: this task can be used to set up a mini goal to achieve in the web which most likely results in navigating the web, like filling a form in the page, clicking a button in the page to open or navigate to another page, interacting with some elements in the page like clicking, typing and selecting options, and so on.- extract: extract information users would like to output from the page. When planning such a task, you should not expect anything related to navigation mentioned in the "navigate" task. The website will remain still and the only action here is to extract information from it.-- loop: this task can be used to generate a list of planning sessions like this. When to use a loop task? Use loop when there are multiple parallel tasks you can do with the same goal. Each task in the loop has the same goal but with different objects/values/targets/variables. Use loop task when it's in a "breadth first search" situation where you can go through a list of values and execute the same task for each value. Examples:+- loop: this task can be used to generate a list of planning sessions like this. When to use a loop task? Use loop when there are multiple parallel tasks you can do with the same goal. Each task in the loop has the same goal but with different objects/values/targets/variables. Use loop task when it's in a "breadth first search" situation where you can go through a list of values and execute the same task for each value. PREFER a loop task whenever the goal repeats the same operation across multiple items, pages, links, rows, or entities — visiting each of N results, collecting the same fields from each of N products, checking each of N pages. One loop handles all N items in a single planned task. Examples:- When the goal is "Open up to 10 links from an ecomm search result page, and extract information like the price of each product.", loop task should be used to iterate through a list of links or URLs. In each iteration of the loop, the task will go to the linked page and trigger another planning session with the goal of extracting price information of the product- When the goal is "download 5 documents found on a page", loop task should be used to iterate through a list of document names. Each document will trigger another planning session to download the relative document+ - When the goal is "compare a field across 10 items", use ONE loop over the 10 items — do NOT plan 10 separate navigate+extract task pairs++**Loop preference:** Do NOT decompose repeated same-shape work into many sequential one-off navigate/extract tasks. Iterating N items as N separate planned tasks exhausts the planning-iteration and step budget and usually runs out before finishing; a single loop task does the same work in one planning step. Reach for a loop as soon as you can enumerate (or will discover on the page) a list of similar targets, even before you know the exact count.When a tool or page caps how many items can be added in a single operation (for example a maximum number of destinations, stops, rows, or selections per request), do NOT keep retrying past that cap. Decompose the work into multiple segments that each stay within the cap, complete each segment in turn, and combine or carry forward the results toward the overall goal. A loop task is often a good fit for iterating through these segments.