diff --git a/docs/tracing.md b/docs/tracing.md index d73a644209..b9cc14a22d 100644 --- a/docs/tracing.md +++ b/docs/tracing.md @@ -139,11 +139,19 @@ Spans are automatically part of the current trace, and are nested under the near Certain spans may capture potentially sensitive data. -The `generation_span()` stores the inputs/outputs of the LLM generation, and `function_span()` stores the inputs/outputs of function calls. These may contain sensitive data, so you can disable capturing that data via [`RunConfig.trace_include_sensitive_data`][agents.run.RunConfig.trace_include_sensitive_data]. +The `generation_span()` stores the inputs/outputs of the LLM generation, and `function_span()` stores the inputs/outputs of function calls. These may contain sensitive data, so you can control capturing that data via [`RunConfig.trace_include_sensitive_data`][agents.run.RunConfig.trace_include_sensitive_data]. Similarly, Audio spans include base64-encoded PCM data for input and output audio by default. You can disable capturing this audio data by configuring [`VoicePipelineConfig.trace_include_sensitive_audio_data`][agents.voice.pipeline_config.VoicePipelineConfig.trace_include_sensitive_audio_data]. -By default, `trace_include_sensitive_data` is `True`. You can set the default without code by exporting the `OPENAI_AGENTS_TRACE_INCLUDE_SENSITIVE_DATA` environment variable to `true/1` or `false/0` before running your app. +By default, `trace_include_sensitive_data` is `False`. Applications that intentionally need model and tool inputs/outputs in traces must opt in explicitly, either in code: + +```python +from agents import RunConfig + +run_config = RunConfig(trace_include_sensitive_data=True) +``` + +or by exporting `OPENAI_AGENTS_TRACE_INCLUDE_SENSITIVE_DATA=true` (also accepts `1`, `yes`, or `on`). Setting the option explicitly is recommended for applications migrating from releases where sensitive trace data was included by default. ## Custom tracing processors diff --git a/src/agents/run_config.py b/src/agents/run_config.py index cf28ec5cf8..e449fa510e 100644 --- a/src/agents/run_config.py +++ b/src/agents/run_config.py @@ -51,7 +51,7 @@ def _default_trace_include_sensitive_data() -> bool: """Return the default for trace_include_sensitive_data based on environment.""" - val = os.getenv("OPENAI_AGENTS_TRACE_INCLUDE_SENSITIVE_DATA", "true") + val = os.getenv("OPENAI_AGENTS_TRACE_INCLUDE_SENSITIVE_DATA", "false") return val.strip().lower() in ("1", "true", "yes", "on") diff --git a/src/agents/voice/pipeline_config.py b/src/agents/voice/pipeline_config.py index 35c55d093a..4a292dcafb 100644 --- a/src/agents/voice/pipeline_config.py +++ b/src/agents/voice/pipeline_config.py @@ -23,9 +23,10 @@ class VoicePipelineConfig: tracing: TracingConfig | None = None """Tracing configuration for this pipeline.""" - trace_include_sensitive_data: bool = True - """Whether to include sensitive data in traces. Defaults to `True`. This is specifically for the - voice pipeline, and not for anything that goes on inside your Workflow.""" + trace_include_sensitive_data: bool = False + """Whether to include sensitive data in traces. Defaults to `False` for security. When enabled, + tool inputs/outputs and LLM generations may be exposed in traces. Only enable in trusted + environments.""" trace_include_sensitive_audio_data: bool = True """Whether to include audio data in traces. Defaults to `True`.""" diff --git a/tests/test_run_config.py b/tests/test_run_config.py index 8c88046af5..39cd30b35d 100644 --- a/tests/test_run_config.py +++ b/tests/test_run_config.py @@ -274,11 +274,11 @@ async def test_agent_model_object_is_used_when_present() -> None: assert result.final_output == "from-agent-object" -def test_trace_include_sensitive_data_defaults_to_true_when_env_not_set(monkeypatch): - """By default, trace_include_sensitive_data should be True when the env is not set.""" +def test_trace_include_sensitive_data_defaults_to_false_when_env_not_set(monkeypatch): + """By default, trace_include_sensitive_data should be False for security when the env is not set.""" monkeypatch.delenv("OPENAI_AGENTS_TRACE_INCLUDE_SENSITIVE_DATA", raising=False) config = RunConfig() - assert config.trace_include_sensitive_data is True + assert config.trace_include_sensitive_data is False @pytest.mark.parametrize(