Skip to content

Commit 64275de

Browse files
Merge pull request #130 from scaleapi/dm/data-converter-openai-agents-sdk
feat. Unset pydantic_data_converter if OpenAI Agents plugin being used
2 parents b272739 + 9f5b076 commit 64275de

File tree

1 file changed

+18
-13
lines changed
  • src/agentex/lib/core/clients/temporal

1 file changed

+18
-13
lines changed

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

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from temporalio.client import Client, Plugin as ClientPlugin
44
from temporalio.runtime import Runtime, TelemetryConfig, OpenTelemetryConfig
55
from temporalio.contrib.pydantic import pydantic_data_converter
6+
from temporalio.contrib.openai_agents import OpenAIAgentsPlugin
67

78
# class DateTimeJSONEncoder(AdvancedJSONEncoder):
89
# def default(self, o: Any) -> Any:
@@ -74,20 +75,24 @@ async def get_temporal_client(temporal_address: str, metrics_url: str | None = N
7475
if plugins:
7576
validate_client_plugins(plugins)
7677

78+
# Check if OpenAI plugin is present - it needs to configure its own data converter
79+
has_openai_plugin = any(
80+
isinstance(p, OpenAIAgentsPlugin) for p in (plugins or [])
81+
)
82+
83+
# Only set data_converter if OpenAI plugin is not present
84+
connect_kwargs = {
85+
"target_host": temporal_address,
86+
"plugins": plugins,
87+
}
88+
89+
if not has_openai_plugin:
90+
connect_kwargs["data_converter"] = pydantic_data_converter
91+
7792
if not metrics_url:
78-
client = await Client.connect(
79-
target_host=temporal_address,
80-
# data_converter=custom_data_converter,
81-
data_converter=pydantic_data_converter,
82-
plugins=plugins,
83-
)
93+
client = await Client.connect(**connect_kwargs)
8494
else:
8595
runtime = Runtime(telemetry=TelemetryConfig(metrics=OpenTelemetryConfig(url=metrics_url)))
86-
client = await Client.connect(
87-
target_host=temporal_address,
88-
# data_converter=custom_data_converter,
89-
data_converter=pydantic_data_converter,
90-
runtime=runtime,
91-
plugins=plugins,
92-
)
96+
connect_kwargs["runtime"] = runtime
97+
client = await Client.connect(**connect_kwargs)
9398
return client

0 commit comments

Comments
 (0)