Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
Remove Sentry error tracking entirely (#1038)
r33drichardsc534d1931c83
diff --git a/libs/python/agent/agent/agent.py b/libs/python/agent/agent/agent.pyindex dbf11adcf6..23d691c7dd 100644--- a/libs/python/agent/agent/agent.py+++ b/libs/python/agent/agent/agent.py@@ -321,7 +321,6 @@ class ComputerAgent:self.callbacks.append(TelemetryCallback(self, **self.telemetry_enabled))# OpenTelemetry callback (operational metrics - Four Golden Signals)- # This is enabled alongside PostHog when telemetry_enabled is True# Users can disable via CUA_TELEMETRY_DISABLED=true env varself.callbacks.append(OtelCallback(self))diff --git a/libs/python/agent/agent/callbacks/otel.py b/libs/python/agent/agent/callbacks/otel.pyindex f71acb1ba6..742a368d76 100644--- a/libs/python/agent/agent/callbacks/otel.py+++ b/libs/python/agent/agent/callbacks/otel.py@@ -16,14 +16,11 @@ from .base import AsyncCallbackHandler# Import OTEL functions - these are available when cua-core[telemetry] is installedtry:from core.telemetry import (- add_breadcrumb,- capture_exception,create_span,is_otel_enabled,record_error,record_operation,record_tokens,- set_context,track_concurrent,)@@ -70,16 +67,6 @@ class OtelCallback(AsyncCallbackHandler):# Track concurrent sessionsself._concurrent_tracker: Optional[Any] = None- if OTEL_AVAILABLE and is_otel_enabled():- # Set context for all events- set_context(- "agent",- {- "model": self.model,- "agent_type": self._get_agent_type(),- },- )-def _get_agent_type(self) -> str:"""Get the agent loop type name."""if hasattr(self.agent, "agent_loop") and self.agent.agent_loop is not None:@@ -94,18 +81,6 @@ class OtelCallback(AsyncCallbackHandler):self.run_start_time = time.perf_counter()self.step_count = 0- # Add breadcrumb for debugging- add_breadcrumb(- category="agent",- message=f"Agent run started with model {self.model}",- level="info",- data={- "model": self.model,- "agent_type": self._get_agent_type(),- "input_messages": len(old_items),- },- )-async def on_run_end(self,kwargs: Dict[str, Any],@@ -128,17 +103,6 @@ class OtelCallback(AsyncCallbackHandler):steps=self.step_count,)- add_breadcrumb(- category="agent",- message=f"Agent run completed in {duration:.2f}s",- level="info",- data={- "duration_seconds": duration,- "steps": self.step_count,- "output_messages": len(new_items),- },- )-self.run_start_time = Noneasync def on_responses(self, kwargs: Dict[str, Any], responses: Dict[str, Any]) -> None:@@ -163,13 +127,6 @@ class OtelCallback(AsyncCallbackHandler):# Start timing next stepself.step_start_time = current_time- add_breadcrumb(- category="agent",- message=f"Agent step {self.step_count} completed",- level="info",- data={"step": self.step_count},- )-async def on_usage(self, usage: Dict[str, Any]) -> None:"""Called when usage information is received."""if not OTEL_AVAILABLE or not is_otel_enabled():@@ -190,16 +147,6 @@ class OtelCallback(AsyncCallbackHandler):if not OTEL_AVAILABLE or not is_otel_enabled():return- action = item.get("action", {})- action_type = action.get("type", "unknown")-- add_breadcrumb(- category="computer",- message=f"Computer action: {action_type}",- level="info",- data={"action_type": action_type},- )-async def on_computer_call_end(self, item: Dict[str, Any], result: List[Dict[str, Any]]) -> None:@@ -225,28 +172,15 @@ class OtelCallback(AsyncCallbackHandler):if not OTEL_AVAILABLE or not is_otel_enabled():return- add_breadcrumb(- category="llm",- message="LLM API call started",- level="info",- data={"model": self.model},- )-async def on_api_end(self, kwargs: Dict[str, Any], result: Any) -> None:"""Called when an LLM API call has completed."""if not OTEL_AVAILABLE or not is_otel_enabled():return- add_breadcrumb(- category="llm",- message="LLM API call completed",- level="info",- )-class OtelErrorCallback(AsyncCallbackHandler):"""- Callback that captures errors and sends them to Sentry/OTEL.+ Callback that captures errors and sends them to OTEL.Should be added early in the callback chain to catch all errors."""@@ -275,13 +209,3 @@ class OtelErrorCallback(AsyncCallbackHandler):operation=operation,model=self.model,)-- # Capture exception in Sentry- capture_exception(- error,- context={- "model": self.model,- "operation": operation,- **{k: v for k, v in context.items() if k != "operation"},- },- )diff --git a/libs/python/computer/computer/computer.py b/libs/python/computer/computer/computer.pyindex 7ce856eb59..8b1065bebb 100644--- a/libs/python/computer/computer/computer.py+++ b/libs/python/computer/computer/computer.py@@ -45,8 +45,6 @@ from .tracing_wrapper import TracingInterfaceWrapper# Import OTEL functions for session-level metricstry:from core.telemetry import (- add_breadcrumb,- capture_exception,is_otel_enabled,record_operation,track_concurrent,@@ -659,16 +657,6 @@ class Computer:os_type=self.os_type,provider=str(self.provider_type),)- add_breadcrumb(- category="computer",- message=f"Computer session started ({self.os_type})",- level="info",- data={- "os_type": self.os_type,- "provider": str(self.provider_type),- "duration_seconds": duration_seconds,- },- )except Exception as e:# Record failed session startif OTEL_AVAILABLE and is_otel_enabled() and self._telemetry_enabled:@@ -679,13 +667,6 @@ class Computer:status="error",os_type=self.os_type,)- capture_exception(- e,- context={- "operation": "computer.session.start",- "os_type": self.os_type,- },- )raisefinally:# Log initialization time for performance monitoring@@ -736,15 +717,6 @@ class Computer:status="success",os_type=self.os_type,)- add_breadcrumb(- category="computer",- message=f"Computer session stopped ({self.os_type})",- level="info",- data={- "os_type": self.os_type,- "duration_seconds": duration_seconds,- },- )except Exception as e:self.logger.debug(f"Error during cleanup: {e}"diff --git a/libs/python/computer/computer/otel_wrapper.py b/libs/python/computer/computer/otel_wrapper.pyindex 56804ff4d2..59aaed23c1 100644--- a/libs/python/computer/computer/otel_wrapper.py+++ b/libs/python/computer/computer/otel_wrapper.py@@ -15,8 +15,6 @@ from .interface.base import BaseComputerInterface# Import OTEL functions - available when cua-core[telemetry] is installedtry:from core.telemetry import (- add_breadcrumb,- capture_exception,create_span,is_otel_enabled,record_error,@@ -133,15 +131,6 @@ class OtelInterfaceWrapper:status = "success"error_type = None- # Add breadcrumb for debugging- if OTEL_AVAILABLE:- add_breadcrumb(- category="computer",- message=f"Computer action: {name}",- level="info",- data={"action": name, "os_type": self._os_type},- )-try:with create_span(f"computer.{name}",@@ -154,15 +143,6 @@ class OtelInterfaceWrapper:status = "error"error_type = type(e).__name__- # Capture exception in Sentry- if OTEL_AVAILABLE:- capture_exception(- e,- context={- "action": name,- "os_type": self._os_type,- },- )raisefinally:diff --git a/libs/python/core/core/telemetry/__init__.py b/libs/python/core/core/telemetry/__init__.pyindex cc763a1419..19374123a2 100644--- a/libs/python/core/core/telemetry/__init__.py+++ b/libs/python/core/core/telemetry/__init__.py@@ -1,7 +1,7 @@"""This module provides the core telemetry functionality for Cua libraries.-It provides a low-overhead way to collect anonymous usage data via PostHog,-operational metrics via OpenTelemetry, and error tracking via Sentry.+It provides a low-overhead way to collect anonymous usage data via PostHog+and operational metrics via OpenTelemetry."""# OpenTelemetry instrumentation for Four Golden Signals@@ -21,19 +21,6 @@ from core.telemetry.posthog import (record_event,)-# Sentry error tracking-from core.telemetry.sentry import (- add_breadcrumb,- capture_exception,- capture_message,- flush,- is_sentry_enabled,- set_context,- set_tag,- set_user,- start_transaction,-)-__all__ = [# PostHog (product analytics)"record_event",@@ -48,14 +35,4 @@ __all__ = ["create_span","instrument_async","instrument_sync",- # Sentry (error tracking)- "is_sentry_enabled",- "capture_exception",- "capture_message",- "add_breadcrumb",- "set_user",- "set_tag",- "set_context",- "start_transaction",- "flush",]diff --git a/libs/python/core/core/telemetry/sentry.py b/libs/python/core/core/telemetry/sentry.pydeleted file mode 100644index 6503a09767..0000000000--- a/libs/python/core/core/telemetry/sentry.py+++ /dev/null@@ -1,367 +0,0 @@-"""Sentry error tracking for CUA SDK.--Provides error tracking, crash reporting, and performance monitoring.-"""--from __future__ import annotations--import logging-import os-from threading import Lock-from typing import Any, Callable, Dict, Optional, TypeVar--logger = logging.getLogger("core.telemetry.sentry")--# Type vars for decorator-F = TypeVar("F", bound=Callable[..., Any])--# Public Sentry DSN for CUA SDK-# This is intentionally public - it only allows sending events to our project-PUBLIC_SENTRY_DSN = "https://d3fed5d05939cb8343dfcab552948d17@o4510539933483008.ingest.us.sentry.io/4510551288381440"--# Lazy initialization state-_initialized = False-_init_lock = Lock()-_sentry_sdk: Optional[Any] = None---def is_sentry_enabled() -> bool:- """Check if Sentry is enabled.-- Returns True unless CUA_TELEMETRY_DISABLED is set to a truthy value.- """- disabled = os.environ.get("CUA_TELEMETRY_DISABLED", "").lower()- return disabled not in {"1", "true", "yes", "on"}---def _get_sentry_dsn() -> str:- """Get the Sentry DSN."""- return os.environ.get("CUA_SENTRY_DSN", PUBLIC_SENTRY_DSN)---def _get_sdk_version() -> str:- """Get the CUA SDK version."""- try:- from core import __version__-- return __version__- except ImportError:- return "unknown"---def _get_environment() -> str:- """Get the environment name."""- return os.environ.get("CUA_ENVIRONMENT", "production")---def _initialize_sentry() -> bool:- """Initialize Sentry SDK.-- Returns True if initialization succeeded, False otherwise.- Thread-safe via lock.- """- global _initialized, _sentry_sdk-- if _initialized:- return True-- with _init_lock:- # Double-check after acquiring lock- if _initialized:- return True-- if not is_sentry_enabled():- logger.debug("Sentry disabled via CUA_TELEMETRY_DISABLED")- return False-- try:- import sentry_sdk- from sentry_sdk.integrations.logging import LoggingIntegration-- _sentry_sdk = sentry_sdk-- # Configure logging integration to capture warnings and above- logging_integration = LoggingIntegration(- level=logging.WARNING,- event_level=logging.ERROR,- )-- sentry_sdk.init(- dsn=_get_sentry_dsn(),- environment=_get_environment(),- release=f"cua-sdk@{_get_sdk_version()}",- # Performance monitoring- traces_sample_rate=0.1, # 10% of transactions- # Only send errors, not all transactions- profiles_sample_rate=0.0,- # Integrations- integrations=[logging_integration],- # Don't send PII- send_default_pii=False,- # Attach stacktrace to messages- attach_stacktrace=True,- # Set max breadcrumbs- max_breadcrumbs=50,- # Before send hook to filter sensitive data- before_send=_before_send,- )-- # Set default tags- sentry_sdk.set_tag("sdk.name", "cua-sdk")- sentry_sdk.set_tag("sdk.version", _get_sdk_version())-- _initialized = True- logger.info("Sentry initialized")- return True-- except ImportError as e:- logger.warning(- f"Sentry SDK not installed: {e}. " "Install with: pip install sentry-sdk"- )- return False- except Exception as e:- logger.warning(f"Failed to initialize Sentry: {e}")- return False---def _before_send(event: Dict[str, Any], hint: Dict[str, Any]) -> Optional[Dict[str, Any]]:- """Filter sensitive data before sending to Sentry."""- # Remove any potential PII from breadcrumbs- if "breadcrumbs" in event:- for breadcrumb in event.get("breadcrumbs", {}).get("values", []):- # Filter out any data that might contain prompts or user content- if "data" in breadcrumb:- data = breadcrumb["data"]- for key in list(data.keys()):- if any(- sensitive in key.lower()- for sensitive in ["prompt", "content", "message", "text", "input", "output"]- ):- data[key] = "[FILTERED]"-- # Remove sensitive context- if "contexts" in event:- contexts = event["contexts"]- for key in list(contexts.keys()):- if any(sensitive in key.lower() for sensitive in ["prompt", "content", "message"]):- del contexts[key]-- return event---# --- Public API ------def capture_exception(- error: Optional[BaseException] = None,- context: Optional[Dict[str, Any]] = None,-) -> Optional[str]:- """Capture an exception and send to Sentry.-- Args:- error: The exception to capture. If None, captures current exception.- context: Additional context to attach to the event.-- Returns:- Event ID if captured, None otherwise.- """- if not _initialize_sentry() or _sentry_sdk is None:- return None-- try:- with _sentry_sdk.push_scope() as scope:- if context:- for key, value in context.items():- # Don't include potentially sensitive data- if not any(- sensitive in key.lower()- for sensitive in ["prompt", "content", "message", "text"]- ):- scope.set_extra(key, value)-- return _sentry_sdk.capture_exception(error)- except Exception as e:- logger.debug(f"Failed to capture exception: {e}")- return None---def capture_message(- message: str,- level: str = "info",- context: Optional[Dict[str, Any]] = None,-) -> Optional[str]:- """Capture a message and send to Sentry.-- Args:- message: The message to capture.- level: Log level (debug, info, warning, error, fatal).- context: Additional context to attach to the event.-- Returns:- Event ID if captured, None otherwise.- """- if not _initialize_sentry() or _sentry_sdk is None:- return None-- try:- with _sentry_sdk.push_scope() as scope:- if context:- for key, value in context.items():- if not any(- sensitive in key.lower()- for sensitive in ["prompt", "content", "message", "text"]- ):- scope.set_extra(key, value)-- return _sentry_sdk.capture_message(message, level=level)- except Exception as e:- logger.debug(f"Failed to capture message: {e}")- return None---def add_breadcrumb(- category: str,- message: str,- level: str = "info",- data: Optional[Dict[str, Any]] = None,-) -> None:- """Add a breadcrumb for debugging context.-- Args:- category: Breadcrumb category (e.g., "agent", "computer")- message: Breadcrumb message- level: Log level- data: Additional data (will be filtered for sensitive content)- """- if not _initialize_sentry() or _sentry_sdk is None:- return-- try:- # Filter sensitive data- filtered_data = {}- if data:- for key, value in data.items():- if not any(- sensitive in key.lower()- for sensitive in ["prompt", "content", "message", "text", "input", "output"]- ):- filtered_data[key] = value-- _sentry_sdk.add_breadcrumb(- category=category,- message=message,- level=level,- data=filtered_data if filtered_data else None,- )- except Exception as e:- logger.debug(f"Failed to add breadcrumb: {e}")---def set_user(user_id: str) -> None:- """Set the user context (installation ID, not PII).-- Args:- user_id: Anonymous user/installation ID- """- if not _initialize_sentry() or _sentry_sdk is None:- return-- try:- _sentry_sdk.set_user({"id": user_id})- except Exception as e:- logger.debug(f"Failed to set user: {e}")---def set_tag(key: str, value: str) -> None:- """Set a tag on all future events.-- Args:- key: Tag key- value: Tag value- """- if not _initialize_sentry() or _sentry_sdk is None:- return-- try:- _sentry_sdk.set_tag(key, value)- except Exception as e:- logger.debug(f"Failed to set tag: {e}")---def set_context(name: str, data: Dict[str, Any]) -> None:- """Set a context on all future events.-- Args:- name: Context name- data: Context data (will be filtered for sensitive content)- """- if not _initialize_sentry() or _sentry_sdk is None:- return-- try:- # Filter sensitive data- filtered_data = {}- for key, value in data.items():- if not any(- sensitive in key.lower()- for sensitive in ["prompt", "content", "message", "text", "input", "output"]- ):- filtered_data[key] = value-- _sentry_sdk.set_context(name, filtered_data)- except Exception as e:- logger.debug(f"Failed to set context: {e}")---def start_transaction(- name: str,- op: str,- description: Optional[str] = None,-) -> Any:- """Start a performance transaction.-- Args:- name: Transaction name- op: Operation type (e.g., "agent.run", "computer.action")- description: Optional description-- Returns:- Transaction object (use as context manager)-- Example:- with start_transaction("agent.run", "agent") as transaction:- # do work- transaction.set_tag("model", "claude-3")- """- if not _initialize_sentry() or _sentry_sdk is None:- # Return a no-op context manager- from contextlib import nullcontext-- return nullcontext()-- try:- return _sentry_sdk.start_transaction(- name=name,- op=op,- description=description,- )- except Exception as e:- logger.debug(f"Failed to start transaction: {e}")- from contextlib import nullcontext-- return nullcontext()---def flush(timeout: float = 2.0) -> None:- """Flush pending events to Sentry.-- Args:- timeout: Timeout in seconds- """- if not _initialized or _sentry_sdk is None:- return-- try:- _sentry_sdk.flush(timeout=timeout)- except Exception as e:- logger.debug(f"Failed to flush Sentry: {e}")diff --git a/libs/python/core/pyproject.toml b/libs/python/core/pyproject.tomlindex 3f08786a73..4706a69cbd 100644--- a/libs/python/core/pyproject.toml+++ b/libs/python/core/pyproject.toml@@ -22,16 +22,11 @@ otel = ["opentelemetry-sdk>=1.20.0","opentelemetry-exporter-otlp-proto-http>=1.20.0",]-# Sentry for error tracking-sentry = [- "sentry-sdk>=1.39.0",-]# All telemetry featurestelemetry = ["opentelemetry-api>=1.20.0","opentelemetry-sdk>=1.20.0","opentelemetry-exporter-otlp-proto-http>=1.20.0",- "sentry-sdk>=1.39.0",][tool.pdm]diff --git a/uv.lock b/uv.lockindex be1ae85fbc..151e34d1ae 100644--- a/uv.lock+++ b/uv.lock@@ -1330,14 +1330,10 @@ otel = [{ name = "opentelemetry-exporter-otlp-proto-http" },{ name = "opentelemetry-sdk" },]-sentry = [- { name = "sentry-sdk" },-]telemetry = [{ name = "opentelemetry-api" },{ name = "opentelemetry-exporter-otlp-proto-http" },{ name = "opentelemetry-sdk" },- { name = "sentry-sdk" },][package.dev-dependencies]@@ -1354,10 +1350,8 @@ requires-dist = [{ name = "opentelemetry-sdk", marker = "extra == 'otel'", specifier = ">=1.20.0" },{ name = "opentelemetry-sdk", marker = "extra == 'telemetry'", specifier = ">=1.20.0" },{ name = "posthog", specifier = ">=3.20.0" },- { name = "sentry-sdk", marker = "extra == 'sentry'", specifier = ">=1.39.0" },- { name = "sentry-sdk", marker = "extra == 'telemetry'", specifier = ">=1.39.0" },]-provides-extras = ["otel", "sentry", "telemetry"]+provides-extras = ["otel", "telemetry"][package.metadata.requires-dev]dev = [{ name = "pytest", specifier = ">=8.3.5" }]@@ -9304,19 +9298,6 @@ wheels = [{ url = "https://files.pythonhosted.org/packages/99/7e/1fb26e8a21613f6200e1ab88824d5d203714162cf2883248b517deb500b7/sentencepiece-0.2.1-cp313-cp313t-macosx_11_0_arm64.whl", hash = "sha256:ad8493bea8432dae8d6830365352350f3b4144415a1d09c4c8cb8d30cf3b6c3c", size = 1254857, upload-time = "2025-08-12T07:00:11.021Z" },]-[[package]]-name = "sentry-sdk"-version = "2.49.0"-source = { registry = "https://pypi.org/simple" }-dependencies = [- { name = "certifi" },- { name = "urllib3" },-]-sdist = { url = "https://files.pythonhosted.org/packages/02/94/23ac26616a883f492428d9ee9ad6eee391612125326b784dbfc30e1e7bab/sentry_sdk-2.49.0.tar.gz", hash = "sha256:c1878599cde410d481c04ef50ee3aedd4f600e4d0d253f4763041e468b332c30", size = 387228, upload-time = "2026-01-08T09:56:25.642Z" }-wheels = [- { url = "https://files.pythonhosted.org/packages/88/43/1c586f9f413765201234541857cb82fda076f4b0f7bad4a0ec248da39cf3/sentry_sdk-2.49.0-py2.py3-none-any.whl", hash = "sha256:6ea78499133874445a20fe9c826c9e960070abeb7ae0cdf930314ab16bb97aa0", size = 415693, upload-time = "2026-01-08T09:56:21.872Z" },-]-[[package]]name = "setuptools"version = "80.9.0"