Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions docs/tracing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Move unreleased tracing guidance to a docs-only change

This line documents the new opt-in default introduced by the accompanying runtime change, so it is not accurate for the latest published package until that behavior is released. Repository policy requires documentation for unreleased behavior to be handled in a separate docs-only pull request coordinated with the release; remove this documentation change from the runtime fix.

AGENTS.md reference: AGENTS.md:L76-L78

Useful? React with 👍 / 👎.


```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

Expand Down
2 changes: 1 addition & 1 deletion src/agents/run_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down
7 changes: 4 additions & 3 deletions src/agents/voice/pipeline_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Align the voice constructor's static default

When static analysis is active, the handwritten VoicePipelineConfig.__init__ declaration below this field still advertises trace_include_sensitive_data=True, although construction now produces False. Editors and other consumers of the static signature therefore report the old security-sensitive default; update that declaration alongside the dataclass field.

AGENTS.md reference: AGENTS.md:L100-L100

Useful? React with 👍 / 👎.

"""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`."""
Expand Down
6 changes: 3 additions & 3 deletions tests/test_run_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down