Skip to content

Commit b7f1c66

Browse files
danielmillerpclaude
andcommitted
Lazy-import OpenAIAgentsPlugin to fix opentelemetry.sdk import error
The top-level import of OpenAIAgentsPlugin in temporal/utils.py triggers the temporalio.contrib.opentelemetry chain which requires opentelemetry-sdk. This breaks all agents (including sync ones) when opentelemetry-sdk is not installed. Moving the import to the only function that uses it (get_temporal_client) avoids this for non-Temporal agents. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0bda3d8 commit b7f1c66

File tree

1 file changed

+2
-1
lines changed
  • src/agentex/lib/core/clients/temporal

1 file changed

+2
-1
lines changed

src/agentex/lib/core/clients/temporal/utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
from temporalio.worker import Interceptor
77
from temporalio.runtime import Runtime, TelemetryConfig, OpenTelemetryConfig
88
from temporalio.contrib.pydantic import pydantic_data_converter
9-
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
109

1110
# class DateTimeJSONEncoder(AdvancedJSONEncoder):
1211
# def default(self, o: Any) -> Any:
@@ -97,6 +96,8 @@ async def get_temporal_client(temporal_address: str, metrics_url: str | None = N
9796
validate_client_plugins(plugins)
9897

9998
# Check if OpenAI plugin is present - it needs to configure its own data converter
99+
# Lazy import to avoid pulling in opentelemetry.sdk for non-Temporal agents
100+
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
100101
has_openai_plugin = any(
101102
isinstance(p, OpenAIAgentsPlugin) for p in (plugins or [])
102103
)

0 commit comments

Comments
 (0)