Skip to content

Automate browser based workflows with AI

rollout termination aware exp for everything (#4084)

LawyZheng21d5cd0f1871
diff --git a/skyvern/forge/agent.py b/skyvern/forge/agent.py
index 165c5a6a0..39300657f 100644
--- a/skyvern/forge/agent.py
+++ b/skyvern/forge/agent.py
@@ -92,7 +92,6 @@ from skyvern.forge.sdk.workflow.context_manager import WorkflowRunContext
from skyvern.forge.sdk.workflow.models.block import (
ActionBlock,
BaseTaskBlock,
- FileDownloadBlock,
ValidationBlock,
)
from skyvern.forge.sdk.workflow.models.workflow import Workflow, WorkflowRun, WorkflowRunStatus
@@ -1388,7 +1387,6 @@ class ForgeAgent:
scraped_page=scraped_page,
task=task,
step=step,
- task_block=task_block,
)
if complete_action is not None:
LOG.info("User goal achieved, executing complete action")
@@ -2027,7 +2025,7 @@ class ForgeAgent:
)
async def complete_verify(
- self, page: Page, scraped_page: ScrapedPage, task: Task, step: Step, task_block: BaseTaskBlock | None = None
+ self, page: Page, scraped_page: ScrapedPage, task: Task, step: Step
) -> CompleteVerifyResult:
LOG.info(
"Checking if user goal is achieved after re-scraping the page",
@@ -2046,33 +2044,29 @@ class ForgeAgent:
actions_and_results_str = await self._get_action_results(task, current_step=step)
# Check if we should use the termination-aware prompt (experiment)
- # Only enabled for file download blocks
use_termination_prompt = False
- is_file_download_block = task_block is not None and isinstance(task_block, FileDownloadBlock)
-
- if is_file_download_block:
- try:
- distinct_id = task.workflow_run_id if task.workflow_run_id else task.task_id
- use_termination_prompt = await app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached(
- "USE_TERMINATION_AWARE_COMPLETE_VERIFICATION",
- distinct_id,
- properties={"organization_id": task.organization_id},
- )
- if use_termination_prompt:
- LOG.info(
- "Experiment enabled: using termination-aware complete verification prompt for file download block",
- task_id=task.task_id,
- workflow_run_id=task.workflow_run_id,
- organization_id=task.organization_id,
- block_type="file_download",
- )
- except Exception as e:
- LOG.warning(
- "Failed to check USE_TERMINATION_AWARE_COMPLETE_VERIFICATION experiment; using legacy behavior",
+ try:
+ distinct_id = task.workflow_run_id if task.workflow_run_id else task.task_id
+ use_termination_prompt = await app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached(
+ "USE_TERMINATION_AWARE_COMPLETE_VERIFICATION",
+ distinct_id,
+ properties={"organization_id": task.organization_id, "task_url": task.url},
+ )
+ if use_termination_prompt:
+ LOG.info(
+ "Experiment enabled: using termination-aware complete verification prompt for file download block",
task_id=task.task_id,
workflow_run_id=task.workflow_run_id,
- error=str(e),
+ organization_id=task.organization_id,
+ block_type="file_download",
)
+ except Exception as e:
+ LOG.warning(
+ "Failed to check USE_TERMINATION_AWARE_COMPLETE_VERIFICATION experiment; using legacy behavior",
+ task_id=task.task_id,
+ workflow_run_id=task.workflow_run_id,
+ error=str(e),
+ )
# Select the appropriate template based on experiment
template_name = "check-user-goal-with-termination" if use_termination_prompt else "check-user-goal"
@@ -2136,7 +2130,7 @@ class ForgeAgent:
return CompleteVerifyResult.model_validate(verification_result)
async def check_user_goal_complete(
- self, page: Page, scraped_page: ScrapedPage, task: Task, step: Step, task_block: BaseTaskBlock | None = None
+ self, page: Page, scraped_page: ScrapedPage, task: Task, step: Step
) -> CompleteAction | TerminateAction | None:
try:
verification_result = await self.complete_verify(
@@ -2144,7 +2138,6 @@ class ForgeAgent:
scraped_page=scraped_page,
task=task,
step=step,
- task_block=task_block,
)
# Check if we should terminate instead of complete
@@ -3512,7 +3505,6 @@ class ForgeAgent:
scraped_page=scraped_page,
task=task,
step=step,
- task_block=task_block,
),
name=f"verify_goal_{step.step_id}",
)