Skip to content

Automate browser based workflows with AI

speculative step with mouse movement (#4679)

LawyZhenge77c46997a8a
diff --git a/skyvern/forge/agent.py b/skyvern/forge/agent.py
index a1617cfe3..235ea5997 100644
--- a/skyvern/forge/agent.py
+++ b/skyvern/forge/agent.py
@@ -1795,6 +1795,7 @@ class ForgeAgent:
async def _speculate_next_step_plan(
self,
+ organization: Organization,
task: Task,
current_step: Step,
next_step: Step,
@@ -1812,6 +1813,9 @@ class ForgeAgent:
try:
next_step.is_speculative = True
+ if page := await browser_state.get_working_page():
+ await self.register_async_operations(organization, task, page)
+
scraped_page, extract_action_prompt, use_caching, prompt_name = await self.build_and_record_step_prompt(
task,
next_step,
@@ -1830,6 +1834,8 @@ class ForgeAgent:
default=app.LLM_API_HANDLER,
)
+ self.async_operation_pool.run_operation(task.task_id, AgentPhase.llm)
+
llm_json_response = await llm_api_handler(
prompt=extract_action_prompt,
prompt_name=prompt_name,
@@ -3766,6 +3772,7 @@ class ForgeAgent:
speculative_task = asyncio.create_task(
self._speculate_next_step_plan(
+ organization=organization,
task=task,
current_step=step,
next_step=next_step,