Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
copilot enforcement: cap repeated POST_SUSPICIOUS_SUCCESS_NUDGE re-emits (SKY-9486) (#5812)
Andrew Neilsonc97d3d97b215
diff --git a/skyvern/forge/sdk/copilot/enforcement.py b/skyvern/forge/sdk/copilot/enforcement.pyindex 72f77f11f..e462f4fbb 100644--- a/skyvern/forge/sdk/copilot/enforcement.py+++ b/skyvern/forge/sdk/copilot/enforcement.py@@ -32,6 +32,10 @@ MAX_INTERMEDIATE_NUDGES = 8MAX_FAILED_TEST_NUDGES = 2MAX_FORMAT_NUDGES = 2MAX_EXPLORE_WITHOUT_WORKFLOW_NUDGES = 2+# Stops the suspicious-success nudge from re-firing forever when the agent has+# correctly diagnosed an unrecoverable block (anti-bot, paywall) and is no+# longer willing to re-run extraction.+MAX_SUSPICIOUS_SUCCESS_NUDGES = 2# Escalate after this many consecutive all-null extraction runs so the agent# inspects browser state instead of re-prompting the extractor.NULL_DATA_STREAK_ESCALATE_AT = 2@@ -454,7 +458,10 @@ def _needs_suspicious_success_nudge(ctx: Any) -> bool:# to the dedicated stop path rather than competing for the nudge slot.if getattr(ctx, "last_test_non_retriable_nav_error", None):return False- return bool(getattr(ctx, "last_test_suspicious_success", False))+ if not getattr(ctx, "last_test_suspicious_success", False):+ return False+ nudge_count = getattr(ctx, "suspicious_success_nudge_count", 0)+ return nudge_count < MAX_SUSPICIOUS_SUCCESS_NUDGESdef _needs_probable_site_block_stop_nudge(ctx: Any) -> bool:@@ -562,6 +569,7 @@ def _check_enforcement(ctx: Any, result: RunResultStreaming | None = None) -> streturn POST_REPEATED_NULL_DATA_NUDGEif _needs_suspicious_success_nudge(ctx):+ ctx.suspicious_success_nudge_count = getattr(ctx, "suspicious_success_nudge_count", 0) + 1return POST_SUSPICIOUS_SUCCESS_NUDGE# Checked before the generic failed-test nudge so a scrape-wall streakdiff --git a/skyvern/forge/sdk/copilot/tools.py b/skyvern/forge/sdk/copilot/tools.pyindex 89d211064..cad091c3f 100644--- a/skyvern/forge/sdk/copilot/tools.py+++ b/skyvern/forge/sdk/copilot/tools.py@@ -2456,6 +2456,7 @@ def _record_run_blocks_result(copilot_ctx: Any, result: dict[str, Any]) -> None:copilot_ctx.last_test_ok = None if (cancelled_by_watchdog and timeout_latched) else run_okcopilot_ctx.last_test_failure_reason = Nonecopilot_ctx.last_test_suspicious_success = False+ copilot_ctx.suspicious_success_nudge_count = 0copilot_ctx.last_test_anti_bot = Nonecopilot_ctx.last_failure_category_top = Nonecopilot_ctx.last_test_non_retriable_nav_error = None