2323 JSONPlainPayloadConverter ,
2424 _JSONTypeConverterUnhandled ,
2525)
26+ from temporalio .contrib .openai_agents import OpenAIAgentsPlugin
2627
2728from agentex .lib .utils .logging import make_logger
2829from agentex .lib .utils .registration import register_agent
@@ -81,18 +82,27 @@ async def get_temporal_client(temporal_address: str, metrics_url: str | None = N
8182 if plugins != []: # We don't need to validate the plugins if they are empty
8283 _validate_plugins (plugins )
8384
85+ # Check if OpenAI plugin is present - it needs to configure its own data converter
86+ has_openai_plugin = any (
87+ isinstance (p , OpenAIAgentsPlugin ) for p in (plugins or [])
88+ )
89+
90+ # Build connection kwargs
91+ connect_kwargs = {
92+ "target_host" : temporal_address ,
93+ "plugins" : plugins ,
94+ }
95+
96+ # Only set data_converter if OpenAI plugin is not present
97+ if not has_openai_plugin :
98+ connect_kwargs ["data_converter" ] = custom_data_converter
99+
84100 if not metrics_url :
85- client = await Client .connect (
86- target_host = temporal_address , data_converter = custom_data_converter , plugins = plugins
87- )
101+ client = await Client .connect (** connect_kwargs )
88102 else :
89103 runtime = Runtime (telemetry = TelemetryConfig (metrics = OpenTelemetryConfig (url = metrics_url )))
90- client = await Client .connect (
91- target_host = temporal_address ,
92- data_converter = custom_data_converter ,
93- runtime = runtime ,
94- plugins = plugins ,
95- )
104+ connect_kwargs ["runtime" ] = runtime
105+ client = await Client .connect (** connect_kwargs )
96106 return client
97107
98108
@@ -102,7 +112,7 @@ def __init__(
102112 task_queue ,
103113 max_workers : int = 10 ,
104114 max_concurrent_activities : int = 10 ,
105- health_check_port : int = 80 ,
115+ health_check_port : int = int ( os . environ . get ( "HEALTH_CHECK_PORT" )) ,
106116 plugins : list = [],
107117 ):
108118 self .task_queue = task_queue
0 commit comments