Skip to content

Commit 9e7dc7a

Browse files
authored
Update agents sdk dependency to latest. (#983)
* Update agents sdk dependency to latest. Add test for newly functional serialization scenarios * Linting * Attempt lint fix, it didn't happen locally * Attempt lint fix * Test cleanup
1 parent 0f3c577 commit 9e7dc7a

File tree

4 files changed

+252
-13
lines changed

4 files changed

+252
-13
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ opentelemetry = [
2626
]
2727
pydantic = ["pydantic>=2.0.0,<3"]
2828
openai-agents = [
29-
"openai-agents >= 0.1,<0.2",
29+
"openai-agents >= 0.2.3,<0.3",
3030
"eval-type-backport>=0.2.2; python_version < '3.10'"
3131
]
3232

temporalio/contrib/openai_agents/_invoke_model_activity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def make_tool(tool: ToolInput) -> Tool:
160160
raise UserError(f"Unknown tool type: {tool.name}")
161161

162162
tools = [make_tool(x) for x in input.get("tools", [])]
163-
handoffs = [
163+
handoffs: list[Handoff[Any, Any]] = [
164164
Handoff(
165165
tool_name=x.tool_name,
166166
tool_description=x.tool_description,

tests/contrib/openai_agents/test_openai.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import json
12
import os
23
import uuid
34
from dataclasses import dataclass
@@ -45,7 +46,7 @@
4546
)
4647
from openai.types.responses.response_function_web_search import ActionSearch
4748
from openai.types.responses.response_prompt_param import ResponsePromptParam
48-
from pydantic import ConfigDict, Field
49+
from pydantic import ConfigDict, Field, TypeAdapter
4950

5051
from temporalio import activity, workflow
5152
from temporalio.client import Client, WorkflowFailureError, WorkflowHandle
@@ -55,6 +56,7 @@
5556
TestModel,
5657
TestModelProvider,
5758
)
59+
from temporalio.contrib.pydantic import pydantic_data_converter
5860
from temporalio.exceptions import CancelledError
5961
from temporalio.testing import WorkflowEnvironment
6062
from tests.contrib.openai_agents.research_agents.research_manager import (
@@ -1757,3 +1759,21 @@ async def test_workflow_method_tools(client: Client):
17571759
execution_timeout=timedelta(seconds=10),
17581760
)
17591761
await workflow_handle.result()
1762+
1763+
1764+
async def test_response_serialization():
1765+
# This should not be used in another test, or this test needs to change to use another unloaded type
1766+
from openai.types.responses.response_output_item import ImageGenerationCall
1767+
1768+
data = json.loads(
1769+
b'{"id": "msg_68757ec43348819d86709f0fcb70316301a1194a3e05b38c","type": "image_generation_call","status": "completed"}'
1770+
)
1771+
call = TypeAdapter(ImageGenerationCall).validate_python(data)
1772+
model_response = ModelResponse(
1773+
output=[
1774+
call,
1775+
],
1776+
usage=Usage(),
1777+
response_id="",
1778+
)
1779+
encoded = await pydantic_data_converter.encode([model_response])

0 commit comments

Comments
 (0)