Skip to content

Fixing issues with openai integration on python 3.9 #918

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ opentelemetry = [
"opentelemetry-sdk>=1.11.1,<2",
]
pydantic = ["pydantic>=2.0.0,<3"]
openai-agents = ["openai-agents >= 0.0.19"]
openai-agents = [
"openai-agents >= 0.0.19,<0.1",
"eval-type-backport>=0.2.2; python_version < '3.10'"
]

[project.urls]
Homepage = "https://github.com/temporalio/sdk-python"
Expand Down
4 changes: 2 additions & 2 deletions temporalio/contrib/openai_agents/invoke_model_activity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import enum
import json
from dataclasses import dataclass
from typing import Any, Optional, TypedDict, Union, cast
from typing import Any, Optional, Union, cast

from agents import (
AgentOutputSchemaBase,
Expand All @@ -24,7 +24,7 @@
WebSearchTool,
)
from agents.models.multi_provider import MultiProvider
from typing_extensions import Required
from typing_extensions import Required, TypedDict

from temporalio import activity, workflow
from temporalio.contrib.openai_agents._heartbeat_decorator import _auto_heartbeater
Expand Down
21 changes: 9 additions & 12 deletions tests/contrib/test_openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,9 @@ async def run(self, prompt: str) -> str:


async def test_hello_world_agent(client: Client):
if sys.version_info < (3, 11):
pytest.skip("Open AI support has type errors on 3.9 and 3.11")
new_config = client.config()
new_config["data_converter"] = open_ai_data_converter
client = Client(**new_config)

with set_open_ai_agent_temporal_overrides(
start_to_close_timeout=timedelta(seconds=10)
Expand Down Expand Up @@ -237,8 +238,9 @@ async def run(self, question: str) -> str:


async def test_tool_workflow(client: Client):
if sys.version_info < (3, 11):
pytest.skip("Open AI support has type errors on 3.9 and 3.11")
new_config = client.config()
new_config["data_converter"] = open_ai_data_converter
client = Client(**new_config)

with set_open_ai_agent_temporal_overrides(
start_to_close_timeout=timedelta(seconds=10)
Expand Down Expand Up @@ -455,8 +457,9 @@ async def run(self, query: str):


async def test_research_workflow(client: Client):
if sys.version_info < (3, 11):
pytest.skip("Open AI support has type errors on 3.9 and 3.11")
new_config = client.config()
new_config["data_converter"] = open_ai_data_converter
client = Client(**new_config)

global response_index
response_index = 0
Expand Down Expand Up @@ -668,9 +671,6 @@ class AgentAsToolsModel(TestModel):


async def test_agents_as_tools_workflow(client: Client):
if sys.version_info < (3, 11):
pytest.skip("Open AI support has type errors on 3.9 and 3.10")

new_config = client.config()
new_config["data_converter"] = open_ai_data_converter
client = Client(**new_config)
Expand Down Expand Up @@ -1027,9 +1027,6 @@ def validate_process_user_message(self, input: ProcessUserMessageInput) -> None:


async def test_customer_service_workflow(client: Client):
if sys.version_info < (3, 11):
pytest.skip("Open AI support has type errors on 3.9 and 3.11")

new_config = client.config()
new_config["data_converter"] = open_ai_data_converter
client = Client(**new_config)
Expand Down
13 changes: 12 additions & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.