@@ -23,6 +23,7 @@ def create_tracer(
2323 run_id : str | None = None ,
2424 api_url : str | None = None ,
2525 logger : SentienceLogger | None = None ,
26+ upload_trace : bool = False ,
2627) -> Tracer :
2728 """
2829 Create tracer with automatic tier detection.
@@ -38,6 +39,9 @@ def create_tracer(
3839 run_id: Unique identifier for this agent run. If not provided, generates UUID.
3940 api_url: Sentience API base URL (default: https://api.sentienceapi.com)
4041 logger: Optional logger instance for logging file sizes and errors
42+ upload_trace: Enable cloud trace upload (default: False). When True and api_key
43+ is provided, traces will be uploaded to cloud. When False, traces
44+ are saved locally only.
4145
4246 Returns:
4347 Tracer configured with appropriate sink
@@ -62,12 +66,12 @@ def create_tracer(
6266 if api_url is None :
6367 api_url = SENTIENCE_API_URL
6468
65- # 0. Check for orphaned traces from previous crashes (if api_key provided)
66- if api_key :
69+ # 0. Check for orphaned traces from previous crashes (if api_key provided and upload enabled )
70+ if api_key and upload_trace :
6771 _recover_orphaned_traces (api_key , api_url )
6872
69- # 1. Try to initialize Cloud Sink (Pro/Enterprise tier)
70- if api_key :
73+ # 1. Try to initialize Cloud Sink (Pro/Enterprise tier) if upload enabled
74+ if api_key and upload_trace :
7175 try :
7276 # Request pre-signed upload URL from backend
7377 response = requests .post (
0 commit comments