Skip to content

Automate browser based workflows with AI

feat(SKY-11348): gate 720p browser recording behind PostHog flag (#6968)

Shuchang Zheng93151f62a65b
diff --git a/skyvern/forge/agent_functions.py b/skyvern/forge/agent_functions.py
index 639df3da4..aaf717a7f 100644
--- a/skyvern/forge/agent_functions.py
+++ b/skyvern/forge/agent_functions.py
@@ -59,6 +59,10 @@ if TYPE_CHECKING:
LOG = structlog.get_logger()
+# Playwright's always-on ffmpeg VP8 encoder scales CPU with pixel count; 720p is the
+# legibility / CPU tradeoff point that the BROWSER_RECORDING_720P flag opts a run into.
+RECORDING_VIDEO_SIZE_720P: dict[str, int] = {"width": 1280, "height": 720}
+
_LLM_CALL_TIMEOUT_SECONDS = 30 # 30s
USELESS_SHAPE_ATTRIBUTE = [SKYVERN_ID_ATTR, "id", "aria-describedby"]
SVG_SHAPE_CONVERTION_ATTEMPTS = 3
@@ -729,6 +733,21 @@ class AgentFunction:
"""
return False
+ async def resolve_recording_video_size(
+ self,
+ current_size: dict[str, int] | None,
+ *,
+ distinct_id: str | None,
+ organization_id: str | None,
+ workflow_permanent_id: str | None = None,
+ ) -> dict[str, int] | None:
+ """Resolve the browser recording resolution for this run.
+
+ Returns ``current_size`` unchanged. Cloud overrides this to opt runs into
+ an elevated resolution behind a feature flag.
+ """
+ return current_size
+
async def should_keep_code_mode_for_workflow_run(
self,
*,
diff --git a/tests/unit/test_proxy_url_custom.py b/tests/unit/test_proxy_url_custom.py
index 51968f42c..2355f53ed 100644
--- a/tests/unit/test_proxy_url_custom.py
+++ b/tests/unit/test_proxy_url_custom.py
@@ -2,6 +2,7 @@ import pytest
from pydantic import ValidationError
from skyvern.config import settings
+from skyvern.forge.agent_functions import AgentFunction
from skyvern.forge.sdk.db.utils import deserialize_proxy_location, serialize_proxy_location
from skyvern.forge.sdk.schemas.browser_profiles import UpdateBrowserProfileRequest
from skyvern.forge.sdk.schemas.credentials import UpdateCredentialRequest
@@ -70,6 +71,18 @@ def test_build_browser_args_uses_configured_recording_size(monkeypatch: pytest.M
assert args["record_video_size"] == {"width": 1280, "height": 720}
+async def test_resolve_recording_video_size_is_noop_in_oss() -> None:
+ agent_function = AgentFunction()
+
+ assert await agent_function.resolve_recording_video_size(None, distinct_id="wr_1", organization_id="o_1") is None
+ existing = {"width": 1280, "height": 720}
+ assert (
+ await agent_function.resolve_recording_video_size(existing, distinct_id="wr_1", organization_id="o_1")
+ == existing
+ )
+
+
def test_deserialize_proxy_location_custom_url_returns_dict() -> None:
result = deserialize_proxy_location('{"url": "http://user:[email protected]:8080"}')
assert result == {"url": "http://user:[email protected]:8080"}