Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
Route scheduled-run finalizers to the derived run id; classify non-timeout activity failures (SKY-12983) (#7842)
Aaron Perez7aae2403988c
diff --git a/skyvern/forge/failure_classifier.py b/skyvern/forge/failure_classifier.pyindex 3cdcd2d18..7be398454 100644--- a/skyvern/forge/failure_classifier.py+++ b/skyvern/forge/failure_classifier.py@@ -12,11 +12,16 @@ def classify_from_failure_reason(failure_reason: str | None,exception: Exception | None = None,fallback_to_unknown: bool = False,+ exception_name: str | None = None,) -> list[dict] | None:"""Classify failure from failure_reason text and/or exception type.Returns list of categories sorted by confidence, or None if no classification.+ ``exception_name`` classifies from a bare exception class name when the instance is+ unavailable — e.g. a Temporal activity failure whose cause type only crosses the+ serialization boundary as a string. Ignored when ``exception`` is provided.+When ``fallback_to_unknown`` is True and no keywords match, returns a singleUNKNOWN category instead of None. Use True for paths that are *always* failures(exception, max_steps, max_retries). Use False (the default) for terminate paths@@ -30,11 +35,11 @@ def classify_from_failure_reason(MAX_STEPS_EXCEEDED, LLM_REASONING_ERROR, INFRASTRUCTURE_ERROR,PARAMETER_BINDING_ERROR, UNKNOWN"""- if not failure_reason and not exception:+ if not failure_reason and not exception and not exception_name:return Nonereason = (failure_reason or "").lower()- exc_name = type(exception).__name__ if exception else ""+ exc_name = type(exception).__name__ if exception else (exception_name or "")categories: list[dict] = []diff --git a/tests/unit/test_failure_classifier.py b/tests/unit/test_failure_classifier.pyindex 732e245d3..7e30a5c36 100644--- a/tests/unit/test_failure_classifier.py+++ b/tests/unit/test_failure_classifier.py@@ -321,3 +321,25 @@ async def test_non_timeout_scraping_reason_stays_data_extraction() -> None:generic_reason = await build_scraping_failed_reason(browser_state, "https://example.com/path", timed_out=False)assert "timeout" not in generic_reason.lower()assert _categories_for(generic_reason, ScrapingFailed(reason=generic_reason)) == ["DATA_EXTRACTION_FAILURE"]+++def test_exception_name_classifies_when_instance_absent() -> None:+ """A bare cause-type name classifies via exception_name — the Temporal activity-failure+ path only carries the class name across the serialization boundary, not the instance."""+ result = classify_from_failure_reason(None, exception_name="BitwardenVaultError", fallback_to_unknown=True)++ assert result is not None+ assert result[0]["category"] == "CREDENTIAL_ERROR"+++def test_exception_name_is_ignored_when_instance_provided() -> None:+ result = classify_from_failure_reason(+ "boom", exception=ElementNotFoundError(), exception_name="BitwardenVaultError"+ )++ assert result is not None+ assert result[0]["category"] == "ELEMENT_NOT_FOUND"+++def test_exception_name_alone_returns_none_when_unrecognized() -> None:+ assert classify_from_failure_reason(None, exception_name="ValueError") is None