Automate browser based workflows with AI
Python aiapiautomationbrowserbrowser-automationcomputergptllmplaywrightpowerautomatepuppeteerpythonrpaseleniumvisionworkflow
fix sync on oss side (#4797)
Shuchang Zhengda175fee70c7
diff --git a/skyvern/analytics.py b/skyvern/analytics.pyindex 2294c2365..e751b94d7 100644--- a/skyvern/analytics.py+++ b/skyvern/analytics.py@@ -1,12 +1,16 @@+import functoolsimport importlib.metadataimport platformfrom typing import Any, Dict+import structlogimport typerfrom posthog import Posthogfrom skyvern.config import settings+LOG = structlog.get_logger(__name__)+posthog = Posthog("phc_bVT2ugnZhMHRWqMvSRHPdeTjaPxQqT3QSsI3r5FlQR5",host="https://app.posthog.com",@@ -23,7 +27,9 @@ def get_oss_version() -> str:return "unknown"[email protected]_cache(maxsize=1)def analytics_metadata() -> Dict[str, Any]:+ # Cached: all fields are process-lifetime constants. Do not add dynamic fields here.return {"os": platform.system().lower(),"oss_version": get_oss_version(),@@ -38,26 +44,15 @@ def capture(event: str,data: dict[str, Any] | None = None,) -> None:- # If telemetry is disabled, don't send any dataif not settings.SKYVERN_TELEMETRY:return- distinct_id = settings.ANALYTICS_ID-- payload: dict[str, Any] = data or {}try:+ distinct_id = settings.ANALYTICS_ID+ payload: dict[str, Any] = data or {}posthog.capture(distinct_id=distinct_id, event=event, properties=payload)- except Exception as e:- payload.update(- {- "capture_error": str(e),- }- )- posthog.capture(- distinct_id=distinct_id,- event="failure",- properties=payload,- )+ except Exception:+ LOG.debug("analytics capture failed", event=event, exc_info=True)# This is the main function that will be called by the typer CLI. This is separate from capture because typerdiff --git a/skyvern/cli/core/result.py b/skyvern/cli/core/result.pyindex 437cf48d2..94757b5bc 100644--- a/skyvern/cli/core/result.py+++ b/skyvern/cli/core/result.py@@ -5,6 +5,8 @@ from dataclasses import dataclass, fieldfrom datetime import datetime, timezonefrom typing import Any+from skyvern import analytics+class ErrorCode:NO_ACTIVE_BROWSER = "NO_ACTIVE_BROWSER"@@ -63,6 +65,19 @@ def make_result(warnings: list[str] | None = None,error: dict[str, Any] | None = None,) -> dict[str, Any]:+ analytics.capture(+ "mcp_tool_call",+ data={+ **analytics.analytics_metadata(),+ "tool": action,+ "ok": ok,+ # "total" is set by Timer.__exit__; None for early-return paths before Timer starts+ "timing_ms": (timing_ms or {}).get("total"),+ "error_code": error.get("code") if error else None,+ "browser_mode": browser_context.mode if browser_context else None,+ "session_id": browser_context.session_id if browser_context else None,+ },+ )return {"ok": ok,"action": action,diff --git a/skyvern/forge/sdk/api/llm/config_registry.py b/skyvern/forge/sdk/api/llm/config_registry.pyindex f1c9d20f6..e79380442 100644--- a/skyvern/forge/sdk/api/llm/config_registry.py+++ b/skyvern/forge/sdk/api/llm/config_registry.py@@ -394,7 +394,7 @@ if settings.ENABLE_ANTHROPIC:"anthropic/claude-opus-4-6",["ANTHROPIC_API_KEY"],supports_vision=True,- add_assistant_prefix=True,+ add_assistant_prefix=False, # Claude 4.6 does not support assistant message prefillmax_completion_tokens=64000,temperature=1, # Claude 4.6 only supports temperature=1),@@ -544,7 +544,7 @@ if settings.ENABLE_BEDROCK:"bedrock/us.anthropic.claude-opus-4-6-v1",["AWS_REGION"],supports_vision=True,- add_assistant_prefix=True,+ add_assistant_prefix=False, # Claude 4.6 does not support assistant message prefillmax_completion_tokens=64000,temperature=1, # Claude 4.6 only supports temperature=1),