rollout termination aware exp for everything (#4084)
This commit is contained in:
@@ -92,7 +92,6 @@ from skyvern.forge.sdk.workflow.context_manager import WorkflowRunContext
|
|||||||
from skyvern.forge.sdk.workflow.models.block import (
|
from skyvern.forge.sdk.workflow.models.block import (
|
||||||
ActionBlock,
|
ActionBlock,
|
||||||
BaseTaskBlock,
|
BaseTaskBlock,
|
||||||
FileDownloadBlock,
|
|
||||||
ValidationBlock,
|
ValidationBlock,
|
||||||
)
|
)
|
||||||
from skyvern.forge.sdk.workflow.models.workflow import Workflow, WorkflowRun, WorkflowRunStatus
|
from skyvern.forge.sdk.workflow.models.workflow import Workflow, WorkflowRun, WorkflowRunStatus
|
||||||
@@ -1388,7 +1387,6 @@ class ForgeAgent:
|
|||||||
scraped_page=scraped_page,
|
scraped_page=scraped_page,
|
||||||
task=task,
|
task=task,
|
||||||
step=step,
|
step=step,
|
||||||
task_block=task_block,
|
|
||||||
)
|
)
|
||||||
if complete_action is not None:
|
if complete_action is not None:
|
||||||
LOG.info("User goal achieved, executing complete action")
|
LOG.info("User goal achieved, executing complete action")
|
||||||
@@ -2027,7 +2025,7 @@ class ForgeAgent:
|
|||||||
)
|
)
|
||||||
|
|
||||||
async def complete_verify(
|
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:
|
) -> CompleteVerifyResult:
|
||||||
LOG.info(
|
LOG.info(
|
||||||
"Checking if user goal is achieved after re-scraping the page",
|
"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)
|
actions_and_results_str = await self._get_action_results(task, current_step=step)
|
||||||
|
|
||||||
# Check if we should use the termination-aware prompt (experiment)
|
# Check if we should use the termination-aware prompt (experiment)
|
||||||
# Only enabled for file download blocks
|
|
||||||
use_termination_prompt = False
|
use_termination_prompt = False
|
||||||
is_file_download_block = task_block is not None and isinstance(task_block, FileDownloadBlock)
|
try:
|
||||||
|
distinct_id = task.workflow_run_id if task.workflow_run_id else task.task_id
|
||||||
if is_file_download_block:
|
use_termination_prompt = await app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached(
|
||||||
try:
|
"USE_TERMINATION_AWARE_COMPLETE_VERIFICATION",
|
||||||
distinct_id = task.workflow_run_id if task.workflow_run_id else task.task_id
|
distinct_id,
|
||||||
use_termination_prompt = await app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached(
|
properties={"organization_id": task.organization_id, "task_url": task.url},
|
||||||
"USE_TERMINATION_AWARE_COMPLETE_VERIFICATION",
|
)
|
||||||
distinct_id,
|
if use_termination_prompt:
|
||||||
properties={"organization_id": task.organization_id},
|
LOG.info(
|
||||||
)
|
"Experiment enabled: using termination-aware complete verification prompt for file download block",
|
||||||
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",
|
|
||||||
task_id=task.task_id,
|
task_id=task.task_id,
|
||||||
workflow_run_id=task.workflow_run_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
|
# Select the appropriate template based on experiment
|
||||||
template_name = "check-user-goal-with-termination" if use_termination_prompt else "check-user-goal"
|
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)
|
return CompleteVerifyResult.model_validate(verification_result)
|
||||||
|
|
||||||
async def check_user_goal_complete(
|
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:
|
) -> CompleteAction | TerminateAction | None:
|
||||||
try:
|
try:
|
||||||
verification_result = await self.complete_verify(
|
verification_result = await self.complete_verify(
|
||||||
@@ -2144,7 +2138,6 @@ class ForgeAgent:
|
|||||||
scraped_page=scraped_page,
|
scraped_page=scraped_page,
|
||||||
task=task,
|
task=task,
|
||||||
step=step,
|
step=step,
|
||||||
task_block=task_block,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Check if we should terminate instead of complete
|
# Check if we should terminate instead of complete
|
||||||
@@ -3512,7 +3505,6 @@ class ForgeAgent:
|
|||||||
scraped_page=scraped_page,
|
scraped_page=scraped_page,
|
||||||
task=task,
|
task=task,
|
||||||
step=step,
|
step=step,
|
||||||
task_block=task_block,
|
|
||||||
),
|
),
|
||||||
name=f"verify_goal_{step.step_id}",
|
name=f"verify_goal_{step.step_id}",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user