Do not run complete verification for extract blocks or tasks without nav goal + disable complete verification for nav blocks in task v2 run (#1973)
This commit is contained in:
@@ -257,6 +257,7 @@ class ForgeAgent:
|
|||||||
close_browser_on_completion: bool = True,
|
close_browser_on_completion: bool = True,
|
||||||
task_block: BaseTaskBlock | None = None,
|
task_block: BaseTaskBlock | None = None,
|
||||||
browser_session_id: str | None = None,
|
browser_session_id: str | None = None,
|
||||||
|
complete_verification: bool = True,
|
||||||
) -> Tuple[Step, DetailedAgentStepOutput | None, Step | None]:
|
) -> Tuple[Step, DetailedAgentStepOutput | None, Step | None]:
|
||||||
workflow_run: WorkflowRun | None = None
|
workflow_run: WorkflowRun | None = None
|
||||||
if task.workflow_run_id:
|
if task.workflow_run_id:
|
||||||
@@ -383,7 +384,12 @@ class ForgeAgent:
|
|||||||
await self.register_async_operations(organization, task, page)
|
await self.register_async_operations(organization, task, page)
|
||||||
|
|
||||||
step, detailed_output = await self.agent_step(
|
step, detailed_output = await self.agent_step(
|
||||||
task, step, browser_state, organization=organization, task_block=task_block
|
task,
|
||||||
|
step,
|
||||||
|
browser_state,
|
||||||
|
organization=organization,
|
||||||
|
task_block=task_block,
|
||||||
|
complete_verification=complete_verification,
|
||||||
)
|
)
|
||||||
await app.AGENT_FUNCTION.post_step_execution(task, step)
|
await app.AGENT_FUNCTION.post_step_execution(task, step)
|
||||||
task = await self.update_task_errors_from_detailed_output(task, detailed_output)
|
task = await self.update_task_errors_from_detailed_output(task, detailed_output)
|
||||||
@@ -519,6 +525,7 @@ class ForgeAgent:
|
|||||||
close_browser_on_completion=close_browser_on_completion,
|
close_browser_on_completion=close_browser_on_completion,
|
||||||
browser_session_id=browser_session_id,
|
browser_session_id=browser_session_id,
|
||||||
task_block=task_block,
|
task_block=task_block,
|
||||||
|
complete_verification=complete_verification,
|
||||||
)
|
)
|
||||||
elif settings.execute_all_steps() and next_step:
|
elif settings.execute_all_steps() and next_step:
|
||||||
return await self.execute_step(
|
return await self.execute_step(
|
||||||
@@ -529,6 +536,7 @@ class ForgeAgent:
|
|||||||
close_browser_on_completion=close_browser_on_completion,
|
close_browser_on_completion=close_browser_on_completion,
|
||||||
browser_session_id=browser_session_id,
|
browser_session_id=browser_session_id,
|
||||||
task_block=task_block,
|
task_block=task_block,
|
||||||
|
complete_verification=complete_verification,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
LOG.info(
|
LOG.info(
|
||||||
@@ -743,6 +751,7 @@ class ForgeAgent:
|
|||||||
browser_state: BrowserState,
|
browser_state: BrowserState,
|
||||||
organization: Organization | None = None,
|
organization: Organization | None = None,
|
||||||
task_block: BaseTaskBlock | None = None,
|
task_block: BaseTaskBlock | None = None,
|
||||||
|
complete_verification: bool = True,
|
||||||
) -> tuple[Step, DetailedAgentStepOutput]:
|
) -> tuple[Step, DetailedAgentStepOutput]:
|
||||||
detailed_agent_step_output = DetailedAgentStepOutput(
|
detailed_agent_step_output = DetailedAgentStepOutput(
|
||||||
scraped_page=None,
|
scraped_page=None,
|
||||||
@@ -1072,7 +1081,13 @@ class ForgeAgent:
|
|||||||
break
|
break
|
||||||
|
|
||||||
task_completes_on_download = task_block and task_block.complete_on_download and task.workflow_run_id
|
task_completes_on_download = task_block and task_block.complete_on_download and task.workflow_run_id
|
||||||
if not has_decisive_action and not task_completes_on_download and not isinstance(task_block, ActionBlock):
|
if (
|
||||||
|
not has_decisive_action
|
||||||
|
and not task_completes_on_download
|
||||||
|
and not isinstance(task_block, ActionBlock)
|
||||||
|
and complete_verification
|
||||||
|
and (task.navigation_goal or task.complete_criterion)
|
||||||
|
):
|
||||||
disable_user_goal_check = app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached(
|
disable_user_goal_check = app.EXPERIMENTATION_PROVIDER.is_feature_enabled_cached(
|
||||||
"DISABLE_USER_GOAL_CHECK",
|
"DISABLE_USER_GOAL_CHECK",
|
||||||
task.task_id,
|
task.task_id,
|
||||||
|
|||||||
@@ -1146,6 +1146,7 @@ async def _generate_navigation_task(
|
|||||||
navigation_goal=navigation_goal,
|
navigation_goal=navigation_goal,
|
||||||
totp_verification_url=totp_verification_url,
|
totp_verification_url=totp_verification_url,
|
||||||
totp_identifier=totp_identifier,
|
totp_identifier=totp_identifier,
|
||||||
|
complete_verification=False,
|
||||||
)
|
)
|
||||||
output_parameter = await app.WORKFLOW_SERVICE.create_output_parameter_for_block(
|
output_parameter = await app.WORKFLOW_SERVICE.create_output_parameter_for_block(
|
||||||
workflow_id=workflow_id,
|
workflow_id=workflow_id,
|
||||||
@@ -1159,6 +1160,7 @@ async def _generate_navigation_task(
|
|||||||
totp_verification_url=totp_verification_url,
|
totp_verification_url=totp_verification_url,
|
||||||
totp_identifier=totp_identifier,
|
totp_identifier=totp_identifier,
|
||||||
output_parameter=output_parameter,
|
output_parameter=output_parameter,
|
||||||
|
complete_verification=False,
|
||||||
),
|
),
|
||||||
[navigation_block_yaml],
|
[navigation_block_yaml],
|
||||||
[],
|
[],
|
||||||
|
|||||||
@@ -346,6 +346,7 @@ class BaseTaskBlock(Block):
|
|||||||
totp_verification_url: str | None = None
|
totp_verification_url: str | None = None
|
||||||
totp_identifier: str | None = None
|
totp_identifier: str | None = None
|
||||||
cache_actions: bool = False
|
cache_actions: bool = False
|
||||||
|
complete_verification: bool = True
|
||||||
|
|
||||||
def get_all_parameters(
|
def get_all_parameters(
|
||||||
self,
|
self,
|
||||||
@@ -601,6 +602,7 @@ class BaseTaskBlock(Block):
|
|||||||
task_block=self,
|
task_block=self,
|
||||||
browser_session_id=browser_session_id,
|
browser_session_id=browser_session_id,
|
||||||
close_browser_on_completion=browser_session_id is None,
|
close_browser_on_completion=browser_session_id is None,
|
||||||
|
complete_verification=self.complete_verification,
|
||||||
)
|
)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# Make sure the task is marked as failed in the database before raising the exception
|
# Make sure the task is marked as failed in the database before raising the exception
|
||||||
|
|||||||
@@ -141,6 +141,7 @@ class TaskBlockYAML(BlockYAML):
|
|||||||
cache_actions: bool = False
|
cache_actions: bool = False
|
||||||
complete_criterion: str | None = None
|
complete_criterion: str | None = None
|
||||||
terminate_criterion: str | None = None
|
terminate_criterion: str | None = None
|
||||||
|
complete_verification: bool = True
|
||||||
|
|
||||||
|
|
||||||
class ForLoopBlockYAML(BlockYAML):
|
class ForLoopBlockYAML(BlockYAML):
|
||||||
@@ -273,6 +274,7 @@ class NavigationBlockYAML(BlockYAML):
|
|||||||
cache_actions: bool = False
|
cache_actions: bool = False
|
||||||
complete_criterion: str | None = None
|
complete_criterion: str | None = None
|
||||||
terminate_criterion: str | None = None
|
terminate_criterion: str | None = None
|
||||||
|
complete_verification: bool = True
|
||||||
|
|
||||||
|
|
||||||
class ExtractionBlockYAML(BlockYAML):
|
class ExtractionBlockYAML(BlockYAML):
|
||||||
@@ -303,6 +305,7 @@ class LoginBlockYAML(BlockYAML):
|
|||||||
cache_actions: bool = False
|
cache_actions: bool = False
|
||||||
complete_criterion: str | None = None
|
complete_criterion: str | None = None
|
||||||
terminate_criterion: str | None = None
|
terminate_criterion: str | None = None
|
||||||
|
complete_verification: bool = True
|
||||||
|
|
||||||
|
|
||||||
class WaitBlockYAML(BlockYAML):
|
class WaitBlockYAML(BlockYAML):
|
||||||
|
|||||||
@@ -1595,6 +1595,7 @@ class WorkflowService:
|
|||||||
cache_actions=block_yaml.cache_actions,
|
cache_actions=block_yaml.cache_actions,
|
||||||
complete_criterion=block_yaml.complete_criterion,
|
complete_criterion=block_yaml.complete_criterion,
|
||||||
terminate_criterion=block_yaml.terminate_criterion,
|
terminate_criterion=block_yaml.terminate_criterion,
|
||||||
|
complete_verification=block_yaml.complete_verification,
|
||||||
)
|
)
|
||||||
elif block_yaml.block_type == BlockType.FOR_LOOP:
|
elif block_yaml.block_type == BlockType.FOR_LOOP:
|
||||||
loop_blocks = [
|
loop_blocks = [
|
||||||
@@ -1747,6 +1748,8 @@ class WorkflowService:
|
|||||||
totp_verification_url=block_yaml.totp_verification_url,
|
totp_verification_url=block_yaml.totp_verification_url,
|
||||||
totp_identifier=block_yaml.totp_identifier,
|
totp_identifier=block_yaml.totp_identifier,
|
||||||
cache_actions=block_yaml.cache_actions,
|
cache_actions=block_yaml.cache_actions,
|
||||||
|
# DO NOT run complete verification for action block
|
||||||
|
complete_verification=False,
|
||||||
max_steps_per_run=1,
|
max_steps_per_run=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -1774,6 +1777,7 @@ class WorkflowService:
|
|||||||
cache_actions=block_yaml.cache_actions,
|
cache_actions=block_yaml.cache_actions,
|
||||||
complete_criterion=block_yaml.complete_criterion,
|
complete_criterion=block_yaml.complete_criterion,
|
||||||
terminate_criterion=block_yaml.terminate_criterion,
|
terminate_criterion=block_yaml.terminate_criterion,
|
||||||
|
complete_verification=block_yaml.complete_verification,
|
||||||
)
|
)
|
||||||
|
|
||||||
elif block_yaml.block_type == BlockType.EXTRACTION:
|
elif block_yaml.block_type == BlockType.EXTRACTION:
|
||||||
@@ -1794,6 +1798,7 @@ class WorkflowService:
|
|||||||
max_retries=block_yaml.max_retries,
|
max_retries=block_yaml.max_retries,
|
||||||
continue_on_failure=block_yaml.continue_on_failure,
|
continue_on_failure=block_yaml.continue_on_failure,
|
||||||
cache_actions=block_yaml.cache_actions,
|
cache_actions=block_yaml.cache_actions,
|
||||||
|
complete_verification=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
elif block_yaml.block_type == BlockType.LOGIN:
|
elif block_yaml.block_type == BlockType.LOGIN:
|
||||||
@@ -1818,6 +1823,7 @@ class WorkflowService:
|
|||||||
cache_actions=block_yaml.cache_actions,
|
cache_actions=block_yaml.cache_actions,
|
||||||
complete_criterion=block_yaml.complete_criterion,
|
complete_criterion=block_yaml.complete_criterion,
|
||||||
terminate_criterion=block_yaml.terminate_criterion,
|
terminate_criterion=block_yaml.terminate_criterion,
|
||||||
|
complete_verification=block_yaml.complete_verification,
|
||||||
)
|
)
|
||||||
|
|
||||||
elif block_yaml.block_type == BlockType.WAIT:
|
elif block_yaml.block_type == BlockType.WAIT:
|
||||||
@@ -1853,6 +1859,7 @@ class WorkflowService:
|
|||||||
totp_identifier=block_yaml.totp_identifier,
|
totp_identifier=block_yaml.totp_identifier,
|
||||||
cache_actions=block_yaml.cache_actions,
|
cache_actions=block_yaml.cache_actions,
|
||||||
complete_on_download=True,
|
complete_on_download=True,
|
||||||
|
complete_verification=False,
|
||||||
)
|
)
|
||||||
elif block_yaml.block_type == BlockType.TaskV2:
|
elif block_yaml.block_type == BlockType.TaskV2:
|
||||||
return TaskV2Block(
|
return TaskV2Block(
|
||||||
@@ -1870,6 +1877,7 @@ class WorkflowService:
|
|||||||
label=block_yaml.label,
|
label=block_yaml.label,
|
||||||
url=block_yaml.url,
|
url=block_yaml.url,
|
||||||
output_parameter=output_parameter,
|
output_parameter=output_parameter,
|
||||||
|
complete_verification=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
raise ValueError(f"Invalid block type {block_yaml.block_type}")
|
raise ValueError(f"Invalid block type {block_yaml.block_type}")
|
||||||
|
|||||||
Reference in New Issue
Block a user