Skip to content

Automate browser based workflows with AI

fix: remove uncapped script regeneration on continue_on_failure block failures (#5326)

pedrohsdb898e41967329
diff --git a/skyvern/forge/sdk/workflow/service.py b/skyvern/forge/sdk/workflow/service.py
index d20a27c79..2acc4abfe 100644
--- a/skyvern/forge/sdk/workflow/service.py
+++ b/skyvern/forge/sdk/workflow/service.py
@@ -143,13 +143,6 @@ BLOCK_TYPES_THAT_SHOULD_BE_CACHED = {
BlockType.FOR_LOOP,
}
-# Wrapper block types whose cached code is structural (loop iteration, branch routing).
-# Their failure during cached execution reflects data/runtime issues, not bad script code.
-# Excluded from continue_on_failure regeneration to prevent infinite version loops (SKY-8554).
-WRAPPER_BLOCK_TYPES = {
- BlockType.FOR_LOOP,
-}
-
def _extract_blocks_info(blocks: list[BLOCK_YAML_TYPES]) -> list[dict[str, str]]:
"""Extract lightweight info from blocks for title generation (limit to first 5)."""
@@ -2359,23 +2352,11 @@ class WorkflowService:
):
blocks_to_update.add(block.label)
- # Invalidate cache for blocks with continue_on_failure=True that failed
- # This ensures the block runs fresh with AI on the next cached run
- if (
- block.label
- and block.continue_on_failure
- and workflow_run_block_result.status != BlockStatus.completed
- and block.block_type in BLOCK_TYPES_THAT_SHOULD_BE_CACHED
- and block.block_type not in WRAPPER_BLOCK_TYPES # SKY-8554: structural wrappers don't need regen
- and block.label in script_blocks_by_label
- ):
- blocks_to_update.add(block.label)
- LOG.info(
- "Block with continue_on_failure failed during cached execution, marking for regeneration",
- block_label=block.label,
- block_status=workflow_run_block_result.status,
- workflow_run_id=workflow_run_id,
- )
+ # NOTE: continue_on_failure block failures are handled by the Script
+ # Reviewer (triggered at end-of-run, capped at 5/day via Redis), NOT by
+ # regenerating the entire script here. The fallback episode is already
+ # recorded and the reviewer will patch the specific block that failed.
+ # See _trigger_script_reviewer() for the capped reviewer flow.
# Track uncached for-loop child blocks for regeneration.
# ForLoopBlock children execute via block.py's execute_loop_helper(),
diff --git a/tests/unit/test_for_loop_regeneration.py b/tests/unit/test_for_loop_regeneration.py
deleted file mode 100644
index 10eac9b02..000000000
--- a/tests/unit/test_for_loop_regeneration.py
+++ /dev/null
@@ -1,37 +0,0 @@
-"""Tests for FOR_LOOP exclusion from continue_on_failure cache invalidation (SKY-8554).
-
-Validates that:
-1. FOR_LOOP blocks are in WRAPPER_BLOCK_TYPES (excluded from invalidation)
-2. FOR_LOOP blocks remain in BLOCK_TYPES_THAT_SHOULD_BE_CACHED (still cacheable)
-3. TASK blocks are NOT in WRAPPER_BLOCK_TYPES (still invalidated on failure)
-"""
-
-from skyvern.forge.sdk.workflow.models.block import BlockType
-
-
-class TestWrapperBlockTypes:
- """Tests for WRAPPER_BLOCK_TYPES constant."""
-
- def test_for_loop_in_wrapper_block_types(self) -> None:
- """FOR_LOOP should be excluded from continue_on_failure invalidation."""
- from skyvern.forge.sdk.workflow.service import WRAPPER_BLOCK_TYPES
-
- assert BlockType.FOR_LOOP in WRAPPER_BLOCK_TYPES
-
- def test_for_loop_still_cacheable(self) -> None:
- """FOR_LOOP should remain in BLOCK_TYPES_THAT_SHOULD_BE_CACHED."""
- from skyvern.forge.sdk.workflow.service import BLOCK_TYPES_THAT_SHOULD_BE_CACHED
-
- assert BlockType.FOR_LOOP in BLOCK_TYPES_THAT_SHOULD_BE_CACHED
-
- def test_task_not_in_wrapper_block_types(self) -> None:
- """TASK blocks should NOT be in WRAPPER_BLOCK_TYPES — they need invalidation."""
- from skyvern.forge.sdk.workflow.service import WRAPPER_BLOCK_TYPES
-
- assert BlockType.TASK not in WRAPPER_BLOCK_TYPES
-
- def test_task_v2_not_in_wrapper_block_types(self) -> None:
- """TaskV2 blocks should NOT be in WRAPPER_BLOCK_TYPES."""
- from skyvern.forge.sdk.workflow.service import WRAPPER_BLOCK_TYPES
-
- assert BlockType.TaskV2 not in WRAPPER_BLOCK_TYPES