Skip to content

Commit d8d7a15

Browse files
Default factory for trace_include_sensitive_data from env
1 parent f20aa40 commit d8d7a15

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/agents/run.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import asyncio
44
import copy
55
import inspect
6+
import os
67
from dataclasses import dataclass, field
78
from typing import Any, Generic, cast
89

@@ -81,6 +82,12 @@ def get_default_agent_runner() -> AgentRunner:
8182
return DEFAULT_AGENT_RUNNER
8283

8384

85+
def _default_trace_include_sensitive_data() -> bool:
86+
"""Returns the default value for trace_include_sensitive_data based on environment variable."""
87+
val = os.getenv("OPENAI_AGENTS_TRACE_INCLUDE_SENSITIVE_DATA", "true")
88+
return val.strip().lower() in ("1", "true", "yes", "on")
89+
90+
8491
@dataclass
8592
class RunConfig:
8693
"""Configures settings for the entire agent run."""
@@ -114,7 +121,9 @@ class RunConfig:
114121
"""Whether tracing is disabled for the agent run. If disabled, we will not trace the agent run.
115122
"""
116123

117-
trace_include_sensitive_data: bool = True
124+
trace_include_sensitive_data: bool = field(
125+
default_factory=_default_trace_include_sensitive_data
126+
)
118127
"""Whether we include potentially sensitive data (for example: inputs/outputs of tool calls or
119128
LLM generations) in traces. If False, we'll still create spans for these events, but the
120129
sensitive data will not be included.

0 commit comments

Comments
 (0)