Skip to content

Commit 5f32068

Browse files
committed
Disable custom data converter when using open ai agents plugin
1 parent 5ca7db0 commit 5f32068

File tree

1 file changed

+19
-9
lines changed
  • src/agentex/lib/core/temporal/workers

1 file changed

+19
-9
lines changed

src/agentex/lib/core/temporal/workers/worker.py

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
JSONPlainPayloadConverter,
2424
_JSONTypeConverterUnhandled,
2525
)
26+
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
2627

2728
from agentex.lib.utils.logging import make_logger
2829
from 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

0 commit comments

Comments
 (0)