diff --git a/src/agents/tracing/provider.py b/src/agents/tracing/provider.py index 29bf0d2d5a..f7f76b8de1 100644 --- a/src/agents/tracing/provider.py +++ b/src/agents/tracing/provider.py @@ -507,10 +507,6 @@ def force_flush(self) -> None: log_model_and_tool_action_error(logger, "Error flushing trace provider", e) def shutdown(self, timeout: float | None = None) -> None: - self._refresh_disabled_flag() - if self._disabled: - return - try: _safe_debug("Shutting down trace provider") self._multi_processor.shutdown(timeout=timeout) diff --git a/tests/test_disabled_trace_provider_shutdown.py b/tests/test_disabled_trace_provider_shutdown.py new file mode 100644 index 0000000000..cbb8fd446c --- /dev/null +++ b/tests/test_disabled_trace_provider_shutdown.py @@ -0,0 +1,16 @@ +from __future__ import annotations + +from unittest.mock import MagicMock + +from agents.tracing.provider import DefaultTraceProvider + + +def test_disabled_trace_provider_still_shuts_down_registered_processors() -> None: + provider = DefaultTraceProvider() + processor = MagicMock() + provider.register_processor(processor) + provider.set_disabled(True) + + provider.shutdown() + + processor.shutdown.assert_called_once_with()