From 5048b3eeb610e2425754cdf7a308d957438609ef Mon Sep 17 00:00:00 2001 From: Aditya Singh Date: Fri, 22 May 2026 03:20:06 -0700 Subject: [PATCH] fix: export TracingConfig, TraceProvider, get_trace_provider, and TraceCtxManager from agents These four names appear in agents.tracing.__all__ but were not re-exported from the top-level agents package. TracingConfig is documented as the value to pass via RunConfig.tracing, get_trace_provider is the natural counterpart to the already-exported set_trace_provider, TraceProvider is the abstract base for custom providers, and TraceCtxManager is used by custom runners and the voice pipeline. Add a regression test that requires every name in agents.tracing.__all__ to also be reachable from agents and to appear in agents.__all__, mirroring tests/test_exception_exports.py. --- src/agents/__init__.py | 8 +++++ tests/tracing/test_tracing_exports.py | 48 +++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/tracing/test_tracing_exports.py diff --git a/src/agents/__init__.py b/src/agents/__init__.py index 9cb7f05fe3..7e93e29df3 100644 --- a/src/agents/__init__.py +++ b/src/agents/__init__.py @@ -214,6 +214,9 @@ SpeechSpanData, TaskSpanData, Trace, + TraceCtxManager, + TraceProvider, + TracingConfig, TracingProcessor, TranscriptionSpanData, TurnSpanData, @@ -227,6 +230,7 @@ generation_span, get_current_span, get_current_trace, + get_trace_provider, guardrail_span, handoff_span, mcp_tools_span, @@ -525,6 +529,7 @@ def enable_verbose_stdout_logging(): "response_span", "set_trace_processors", "set_trace_provider", + "get_trace_provider", "set_tracing_disabled", "speech_group_span", "transcription_span", @@ -534,6 +539,9 @@ def enable_verbose_stdout_logging(): "trace", "turn_span", "Trace", + "TraceCtxManager", + "TraceProvider", + "TracingConfig", "TracingProcessor", "SpanError", "Span", diff --git a/tests/tracing/test_tracing_exports.py b/tests/tracing/test_tracing_exports.py new file mode 100644 index 0000000000..92d3dc6897 --- /dev/null +++ b/tests/tracing/test_tracing_exports.py @@ -0,0 +1,48 @@ +"""Verify that public tracing names are re-exported from the top-level agents package.""" + +import agents +from agents import tracing as tracing_module + + +def test_tracing_config_is_exported_at_top_level() -> None: + # TracingConfig is referenced in docs as the value to pass via RunConfig.tracing, + # so it must be importable from the top-level package without reaching into agents.tracing. + from agents import TracingConfig + + assert TracingConfig is tracing_module.TracingConfig + assert "TracingConfig" in agents.__all__ + + +def test_trace_provider_is_exported_at_top_level() -> None: + # TraceProvider is the abstract base for custom trace providers and is documented as + # part of the tracing extension surface; it should be importable from agents. + from agents import TraceProvider + + assert TraceProvider is tracing_module.TraceProvider + assert "TraceProvider" in agents.__all__ + + +def test_get_trace_provider_is_exported_at_top_level() -> None: + # set_trace_provider is already exported from the top-level package, so its getter + # counterpart should be too. Callers swapping providers commonly need both. + from agents import get_trace_provider + + assert get_trace_provider is tracing_module.get_trace_provider + assert "get_trace_provider" in agents.__all__ + + +def test_trace_ctx_manager_is_exported_at_top_level() -> None: + # TraceCtxManager is used by custom runners and voice pipelines to manage a trace + # lifecycle, and is part of agents.tracing.__all__. + from agents import TraceCtxManager + + assert TraceCtxManager is tracing_module.TraceCtxManager + assert "TraceCtxManager" in agents.__all__ + + +def test_all_public_tracing_names_are_reexported() -> None: + # Every name exposed by agents.tracing.__all__ should also be available from the + # top-level agents package, so users have a single import path for tracing types. + for name in tracing_module.__all__: + assert hasattr(agents, name), f"agents.{name} is not re-exported from agents package" + assert name in agents.__all__, f"{name} is missing from agents.__all__"