Skip to content

Commit c21d9ca

Browse files
author
SentienceDEV
committed
upload trace enablement
1 parent 64f6282 commit c21d9ca

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

predicate/tracer_factory.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def create_tracer(
4949
run_id: str | None = None,
5050
api_url: str | None = None,
5151
logger: SentienceLogger | None = None,
52-
upload_trace: bool = False,
52+
upload_trace: bool | None = None,
5353
goal: str | None = None,
5454
agent_type: str | None = None,
5555
llm_model: str | None = None,
@@ -71,9 +71,10 @@ def create_tracer(
7171
run_id: Unique identifier for this agent run. If not provided, generates UUID.
7272
api_url: Sentience API base URL (default: https://api.sentienceapi.com)
7373
logger: Optional logger instance for logging file sizes and errors
74-
upload_trace: Enable cloud trace upload (default: False). When True and api_key
74+
upload_trace: Enable cloud trace upload. When None (default), automatically
75+
enables cloud upload if api_key is provided. When True and api_key
7576
is provided, traces will be uploaded to cloud. When False, traces
76-
are saved locally only.
77+
are saved locally only regardless of api_key.
7778
goal: User's goal/objective for this trace run. This will be displayed as the
7879
trace name in the frontend. Should be descriptive and action-oriented.
7980
Example: "Add wireless headphones to cart on Amazon"
@@ -133,12 +134,16 @@ def create_tracer(
133134
if api_url is None:
134135
api_url = PREDICATE_API_URL
135136

137+
# Default upload_trace to True when api_key is provided
138+
# This ensures tracing is enabled automatically for Pro/Enterprise tiers
139+
should_upload = upload_trace if upload_trace is not None else (api_key is not None)
140+
136141
# 0. Check for orphaned traces from previous crashes (if api_key provided and upload enabled)
137-
if api_key and upload_trace:
142+
if api_key and should_upload:
138143
_recover_orphaned_traces(api_key, api_url)
139144

140145
# 1. Try to initialize Cloud Sink (Pro/Enterprise tier) if upload enabled
141-
if api_key and upload_trace:
146+
if api_key and should_upload:
142147
try:
143148
# Build metadata object for trace initialization
144149
# Only include non-empty fields to avoid sending empty strings

0 commit comments

Comments
 (0)