Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Fix the action history passed into extract-action prompt (#186)
Kerem Yilmaz871de9447910
diff --git a/skyvern/forge/agent.py b/skyvern/forge/agent.pyindex 79da5f5a1..132a3a9c6 100644--- a/skyvern/forge/agent.py+++ b/skyvern/forge/agent.py@@ -33,6 +33,7 @@ from skyvern.forge.sdk.workflow.models.workflow import Workflow, WorkflowRunfrom skyvern.webeye.actions.actions import (Action,ActionType,+ ActionTypeUnion,CompleteAction,UserDefinedError,WebAction,@@ -600,12 +601,17 @@ class ForgeAgent(Agent):# Get action results from the last app.SETTINGS.PROMPT_ACTION_HISTORY_WINDOW stepssteps = await app.DATABASE.get_task_steps(task_id=task.task_id, organization_id=task.organization_id)window_steps = steps[-1 * SettingsManager.get_settings().PROMPT_ACTION_HISTORY_WINDOW :]- action_results: list[ActionResult] = []+ actions_and_results: list[tuple[ActionTypeUnion, list[ActionResult]]] = []for window_step in window_steps:- if window_step.output and window_step.output.action_results:- action_results.extend(window_step.output.action_results)-- action_results_str = json.dumps([action_result.model_dump() for action_result in action_results])+ if window_step.output and window_step.output.actions_and_results:+ actions_and_results.extend(window_step.output.actions_and_results)++ actions_and_results_str = json.dumps(+ [+ {"action": action.model_dump(), "results": [result.model_dump() for result in results]}+ for action, results in actions_and_results+ ]+ )# Generate the extract action promptnavigation_goal = task.navigation_goalstarting_url = task.url@@ -620,7 +626,7 @@ class ForgeAgent(Agent):current_url=current_url,elements=scraped_page.element_tree_trimmed,data_extraction_goal=task.data_extraction_goal,- action_history=action_results_str,+ action_history=actions_and_results_str,error_code_mapping_str=json.dumps(task.error_code_mapping) if task.error_code_mapping else None,utc_datetime=datetime.utcnow(),)