Skip to content

Commit 6699cd2

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

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
@@ -14,6 +14,7 @@
1414
UnsandboxedWorkflowRunner,
1515
)
1616
from temporalio.runtime import Runtime, TelemetryConfig, OpenTelemetryConfig
17+
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
1718
from temporalio.converter import (
1819
DataConverter,
1920
JSONTypeConverter,
@@ -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)