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
8 changes: 8 additions & 0 deletions src/agents/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@
SpeechSpanData,
TaskSpanData,
Trace,
TraceCtxManager,
TraceProvider,
TracingConfig,
TracingProcessor,
TranscriptionSpanData,
TurnSpanData,
Expand All @@ -227,6 +230,7 @@
generation_span,
get_current_span,
get_current_trace,
get_trace_provider,
guardrail_span,
handoff_span,
mcp_tools_span,
Expand Down Expand Up @@ -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",
Expand All @@ -534,6 +539,9 @@ def enable_verbose_stdout_logging():
"trace",
"turn_span",
"Trace",
"TraceCtxManager",
"TraceProvider",
"TracingConfig",
"TracingProcessor",
"SpanError",
"Span",
Expand Down
48 changes: 48 additions & 0 deletions tests/tracing/test_tracing_exports.py
Original file line number Diff line number Diff line change
@@ -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__"