diff --git a/skyvern/forge/prompts/skyvern/observer.j2 b/skyvern/forge/prompts/skyvern/observer.j2 index 4a44bba4..89011290 100644 --- a/skyvern/forge/prompts/skyvern/observer.j2 +++ b/skyvern/forge/prompts/skyvern/observer.j2 @@ -1,4 +1,4 @@ -You're to assist the user to achieve the user goal in the web, given the DOM elements in the list, the screenshots of the website and the task history list. Plan the next task the use needs to do towards the goal. +You're to assist the user to achieve the user goal in the web, given the DOM elements in the list, the screenshots of the website and the task history list. Plan the next task the user needs to do towards the goal. You 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 buton 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. @@ -14,7 +14,7 @@ Reply in JSON format with the following keys: "page_info": str, // Think step by step. Describe all the useful information in the page related to the user goal. "thoughts": str, // Think step by step. What has been done so far and what is the next reasonable mini goal a human can do foreseeably move towards the overall goal. "user_goal_achieved": bool, // True if the user goal has been completed, false otherwise. If the user is searching for something, looking for information or specifically trying to extract information along side the goal, make sure at least an extract task has happened in the task history before claiming that the goal is achieved. - "plan": str, // The mini goal to achieve to move towards the goal. Include all the necessary and required user information provided by the user goal to achieve the plan. DO NOT come up or hallucinate any data that's not provided in the user goal. Be accurate and precise. Return null if the user goal has been achieved. + "plan": str, // The mini goal to achieve to move towards the user goal. DO NOT come up or hallucinate any data that's not provided in the user goal. Be accurate and precise. Return null if the user goal has been achieved. "task_type": str, // One of the available task types: navigate, extract, loop "loop_values": list[str], // a list of string values to iterate through for loop task. null if it's not a loop task "is_loop_value_link": bool, // true if the loop_values is a list of urls to go to before for each planning session inside the loop diff --git a/skyvern/forge/sdk/services/observer_service.py b/skyvern/forge/sdk/services/observer_service.py index ef506c66..c6f295b9 100644 --- a/skyvern/forge/sdk/services/observer_service.py +++ b/skyvern/forge/sdk/services/observer_service.py @@ -71,6 +71,10 @@ DATA_EXTRACTION_SCHEMA_FOR_LOOP = { }, } +MINI_GOAL_TEMPLATE = """Achieve the following mini goal and once it's achieved, complete: {mini_goal} + +This mini goal is part of the big goal the user wants to achieve and use the big goal as context to achieve the mini goal: {main_goal}""" + class LoopExtractionOutput(BaseModel): loop_values: list[str] @@ -410,12 +414,13 @@ async def run_observer_cruise_helper( task_history_record = {"type": task_type, "task": plan} elif task_type == "navigate": original_url = url if i == 0 else None + navigation_goal = MINI_GOAL_TEMPLATE.format(main_goal=user_prompt, mini_goal=plan) block, block_yaml_list, parameter_yaml_list = await _generate_navigation_task( workflow_id=workflow_id, workflow_permanent_id=workflow.workflow_permanent_id, workflow_run_id=workflow_run_id, original_url=original_url, - navigation_goal=plan, + navigation_goal=navigation_goal, ) task_history_record = {"type": task_type, "task": plan} elif task_type == "loop":