Merge pull request #32 from openai/rm/sdk_bump

Bump open AI sdk version
pin to openai 1.66.2, update tests
make computer use example less verbose
This commit is contained in:
Rohan Mehta 2025-03-11 15:30:57 -07:00 committed by GitHub
commit 8326dd9fa0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 33 additions and 28 deletions

View file

@ -1,6 +1,5 @@
import asyncio import asyncio
import base64 import base64
import logging
from typing import Literal, Union from typing import Literal, Union
from playwright.async_api import Browser, Page, Playwright, async_playwright from playwright.async_api import Browser, Page, Playwright, async_playwright
@ -16,8 +15,10 @@ from agents import (
trace, trace,
) )
logging.getLogger("openai.agents").setLevel(logging.DEBUG) # Uncomment to see very verbose logs
logging.getLogger("openai.agents").addHandler(logging.StreamHandler()) # import logging
# logging.getLogger("openai.agents").setLevel(logging.DEBUG)
# logging.getLogger("openai.agents").addHandler(logging.StreamHandler())
async def main(): async def main():

View file

@ -1,6 +1,6 @@
[project] [project]
name = "openai-agents" name = "openai-agents"
version = "0.0.2" version = "0.0.3"
description = "OpenAI Agents SDK" description = "OpenAI Agents SDK"
readme = "README.md" readme = "README.md"
requires-python = ">=3.9" requires-python = ">=3.9"
@ -9,7 +9,7 @@ authors = [
{ name = "OpenAI", email = "support@openai.com" }, { name = "OpenAI", email = "support@openai.com" },
] ]
dependencies = [ dependencies = [
"openai>=1.66.0", "openai>=1.66.2",
"pydantic>=2.10, <3", "pydantic>=2.10, <3",
"griffe>=1.5.6, <2", "griffe>=1.5.6, <2",
"typing-extensions>=4.12.2, <5", "typing-extensions>=4.12.2, <5",

View file

@ -23,7 +23,7 @@ from openai.types.responses.response_computer_tool_call import (
ActionWait, ActionWait,
) )
from openai.types.responses.response_input_param import ComputerCallOutput from openai.types.responses.response_input_param import ComputerCallOutput
from openai.types.responses.response_output_item import Reasoning from openai.types.responses.response_reasoning_item import ResponseReasoningItem
from . import _utils from . import _utils
from .agent import Agent from .agent import Agent
@ -288,7 +288,7 @@ class RunImpl:
items.append(ToolCallItem(raw_item=output, agent=agent)) items.append(ToolCallItem(raw_item=output, agent=agent))
elif isinstance(output, ResponseFunctionWebSearch): elif isinstance(output, ResponseFunctionWebSearch):
items.append(ToolCallItem(raw_item=output, agent=agent)) items.append(ToolCallItem(raw_item=output, agent=agent))
elif isinstance(output, Reasoning): elif isinstance(output, ResponseReasoningItem):
items.append(ReasoningItem(raw_item=output, agent=agent)) items.append(ReasoningItem(raw_item=output, agent=agent))
elif isinstance(output, ResponseComputerToolCall): elif isinstance(output, ResponseComputerToolCall):
items.append(ToolCallItem(raw_item=output, agent=agent)) items.append(ToolCallItem(raw_item=output, agent=agent))

View file

@ -19,7 +19,7 @@ from openai.types.responses import (
ResponseStreamEvent, ResponseStreamEvent,
) )
from openai.types.responses.response_input_item_param import ComputerCallOutput, FunctionCallOutput from openai.types.responses.response_input_item_param import ComputerCallOutput, FunctionCallOutput
from openai.types.responses.response_output_item import Reasoning from openai.types.responses.response_reasoning_item import ResponseReasoningItem
from pydantic import BaseModel from pydantic import BaseModel
from typing_extensions import TypeAlias from typing_extensions import TypeAlias
@ -136,10 +136,10 @@ class ToolCallOutputItem(RunItemBase[Union[FunctionCallOutput, ComputerCallOutpu
@dataclass @dataclass
class ReasoningItem(RunItemBase[Reasoning]): class ReasoningItem(RunItemBase[ResponseReasoningItem]):
"""Represents a reasoning item.""" """Represents a reasoning item."""
raw_item: Reasoning raw_item: ResponseReasoningItem
"""The raw reasoning item.""" """The raw reasoning item."""
type: Literal["reasoning_item"] = "reasoning_item" type: Literal["reasoning_item"] = "reasoning_item"

View file

@ -361,7 +361,7 @@ class Converter:
includes = "file_search_call.results" if tool.include_search_results else None includes = "file_search_call.results" if tool.include_search_results else None
elif isinstance(tool, ComputerTool): elif isinstance(tool, ComputerTool):
converted_tool = { converted_tool = {
"type": "computer-preview", "type": "computer_use_preview",
"environment": tool.computer.environment, "environment": tool.computer.environment,
"display_width": tool.computer.dimensions[0], "display_width": tool.computer.dimensions[0],
"display_height": tool.computer.dimensions[1], "display_height": tool.computer.dimensions[1],

View file

@ -284,3 +284,5 @@ def function_tool(
return _create_function_tool(real_func) return _create_function_tool(real_func)
return decorator return decorator
return decorator
return decorator

View file

@ -13,12 +13,12 @@ from openai.types.responses.response_function_tool_call import ResponseFunctionT
from openai.types.responses.response_function_tool_call_param import ResponseFunctionToolCallParam from openai.types.responses.response_function_tool_call_param import ResponseFunctionToolCallParam
from openai.types.responses.response_function_web_search import ResponseFunctionWebSearch from openai.types.responses.response_function_web_search import ResponseFunctionWebSearch
from openai.types.responses.response_function_web_search_param import ResponseFunctionWebSearchParam from openai.types.responses.response_function_web_search_param import ResponseFunctionWebSearchParam
from openai.types.responses.response_input_item_param import Reasoning as ReasoningInputParam
from openai.types.responses.response_output_item import Reasoning, ReasoningContent
from openai.types.responses.response_output_message import ResponseOutputMessage from openai.types.responses.response_output_message import ResponseOutputMessage
from openai.types.responses.response_output_message_param import ResponseOutputMessageParam from openai.types.responses.response_output_message_param import ResponseOutputMessageParam
from openai.types.responses.response_output_refusal import ResponseOutputRefusal from openai.types.responses.response_output_refusal import ResponseOutputRefusal
from openai.types.responses.response_output_text import ResponseOutputText from openai.types.responses.response_output_text import ResponseOutputText
from openai.types.responses.response_reasoning_item import ResponseReasoningItem, Summary
from openai.types.responses.response_reasoning_item_param import ResponseReasoningItemParam
from agents import ( from agents import (
Agent, Agent,
@ -129,7 +129,7 @@ def test_text_message_outputs_across_list_of_runitems() -> None:
item1: RunItem = MessageOutputItem(agent=Agent(name="test"), raw_item=message1) item1: RunItem = MessageOutputItem(agent=Agent(name="test"), raw_item=message1)
item2: RunItem = MessageOutputItem(agent=Agent(name="test"), raw_item=message2) item2: RunItem = MessageOutputItem(agent=Agent(name="test"), raw_item=message2)
# Create a non-message run item of a different type, e.g., a reasoning trace. # Create a non-message run item of a different type, e.g., a reasoning trace.
reasoning = Reasoning(id="rid", content=[], type="reasoning") reasoning = ResponseReasoningItem(id="rid", summary=[], type="reasoning")
non_message_item: RunItem = ReasoningItem(agent=Agent(name="test"), raw_item=reasoning) non_message_item: RunItem = ReasoningItem(agent=Agent(name="test"), raw_item=reasoning)
# Confirm only the message outputs are concatenated. # Confirm only the message outputs are concatenated.
assert ItemHelpers.text_message_outputs([item1, non_message_item, item2]) == "foobar" assert ItemHelpers.text_message_outputs([item1, non_message_item, item2]) == "foobar"
@ -266,16 +266,18 @@ def test_to_input_items_for_computer_call_click() -> None:
def test_to_input_items_for_reasoning() -> None: def test_to_input_items_for_reasoning() -> None:
"""A reasoning output should produce the same dict as a reasoning input item.""" """A reasoning output should produce the same dict as a reasoning input item."""
rc = ReasoningContent(text="why", type="reasoning_summary") rc = Summary(text="why", type="summary_text")
reasoning = Reasoning(id="rid1", content=[rc], type="reasoning") reasoning = ResponseReasoningItem(id="rid1", summary=[rc], type="reasoning")
resp = ModelResponse(output=[reasoning], usage=Usage(), referenceable_id=None) resp = ModelResponse(output=[reasoning], usage=Usage(), referenceable_id=None)
input_items = resp.to_input_items() input_items = resp.to_input_items()
assert isinstance(input_items, list) and len(input_items) == 1 assert isinstance(input_items, list) and len(input_items) == 1
converted_dict = input_items[0] converted_dict = input_items[0]
expected: ReasoningInputParam = { expected: ResponseReasoningItemParam = {
"id": "rid1", "id": "rid1",
"content": [{"text": "why", "type": "reasoning_summary"}], "summary": [{"text": "why", "type": "summary_text"}],
"type": "reasoning", "type": "reasoning",
} }
print(converted_dict)
print(expected)
assert converted_dict == expected assert converted_dict == expected

View file

@ -163,7 +163,7 @@ def test_convert_tools_basic_types_and_includes():
assert "function" in types assert "function" in types
assert "file_search" in types assert "file_search" in types
assert "web_search_preview" in types assert "web_search_preview" in types
assert "computer-preview" in types assert "computer_use_preview" in types
# Verify file search tool contains max_num_results and vector_store_ids # Verify file search tool contains max_num_results and vector_store_ids
file_params = next(ct for ct in converted.tools if ct["type"] == "file_search") file_params = next(ct for ct in converted.tools if ct["type"] == "file_search")
assert file_params.get("max_num_results") == file_tool.max_num_results assert file_params.get("max_num_results") == file_tool.max_num_results
@ -173,7 +173,7 @@ def test_convert_tools_basic_types_and_includes():
assert web_params.get("user_location") == web_tool.user_location assert web_params.get("user_location") == web_tool.user_location
assert web_params.get("search_context_size") == web_tool.search_context_size assert web_params.get("search_context_size") == web_tool.search_context_size
# Verify computer tool contains environment and computed dimensions # Verify computer tool contains environment and computed dimensions
comp_params = next(ct for ct in converted.tools if ct["type"] == "computer-preview") comp_params = next(ct for ct in converted.tools if ct["type"] == "computer_use_preview")
assert comp_params.get("environment") == "mac" assert comp_params.get("environment") == "mac"
assert comp_params.get("display_width") == 800 assert comp_params.get("display_width") == 800
assert comp_params.get("display_height") == 600 assert comp_params.get("display_height") == 600

View file

@ -7,7 +7,7 @@ from openai.types.responses import (
ResponseFunctionWebSearch, ResponseFunctionWebSearch,
) )
from openai.types.responses.response_computer_tool_call import ActionClick from openai.types.responses.response_computer_tool_call import ActionClick
from openai.types.responses.response_output_item import Reasoning, ReasoningContent from openai.types.responses.response_reasoning_item import ResponseReasoningItem, Summary
from pydantic import BaseModel from pydantic import BaseModel
from agents import ( from agents import (
@ -287,8 +287,8 @@ def test_function_web_search_tool_call_parsed_correctly():
def test_reasoning_item_parsed_correctly(): def test_reasoning_item_parsed_correctly():
# Verify that a Reasoning output item is converted into a ReasoningItem. # Verify that a Reasoning output item is converted into a ReasoningItem.
reasoning = Reasoning( reasoning = ResponseReasoningItem(
id="r1", type="reasoning", content=[ReasoningContent(text="why", type="reasoning_summary")] id="r1", type="reasoning", summary=[Summary(text="why", type="summary_text")]
) )
response = ModelResponse( response = ModelResponse(
output=[reasoning], output=[reasoning],

10
uv.lock
View file

@ -764,7 +764,7 @@ wheels = [
[[package]] [[package]]
name = "openai" name = "openai"
version = "1.66.0" version = "1.66.2"
source = { registry = "https://pypi.org/simple" } source = { registry = "https://pypi.org/simple" }
dependencies = [ dependencies = [
{ name = "anyio" }, { name = "anyio" },
@ -776,14 +776,14 @@ dependencies = [
{ name = "tqdm" }, { name = "tqdm" },
{ name = "typing-extensions" }, { name = "typing-extensions" },
] ]
sdist = { url = "https://files.pythonhosted.org/packages/84/c5/3c422ca3ccc81c063955e7c20739d7f8f37fea0af865c4a60c81e6225e14/openai-1.66.0.tar.gz", hash = "sha256:8a9e672bc6eadec60a962f0b40d7d1c09050010179c919ed65322e433e2d1025", size = 396819 } sdist = { url = "https://files.pythonhosted.org/packages/d8/e1/b3e1fda1aa32d4f40d4de744e91de4de65c854c3e53c63342e4b5f9c5995/openai-1.66.2.tar.gz", hash = "sha256:9b3a843c25f81ee09b6469d483d9fba779d5c6ea41861180772f043481b0598d", size = 397041 }
wheels = [ wheels = [
{ url = "https://files.pythonhosted.org/packages/d7/f1/d52960dac9519c9de64593460826a0fe2e19159389ec97ecf3e931d2e6a3/openai-1.66.0-py3-none-any.whl", hash = "sha256:43e4a3c0c066cc5809be4e6aac456a3ebc4ec1848226ef9d1340859ac130d45a", size = 566389 }, { url = "https://files.pythonhosted.org/packages/2c/6f/3315b3583ffe3e31c55b446cb22d2a7c235e65ca191674fffae62deb3c11/openai-1.66.2-py3-none-any.whl", hash = "sha256:75194057ee6bb8b732526387b6041327a05656d976fc21c064e21c8ac6b07999", size = 567268 },
] ]
[[package]] [[package]]
name = "openai-agents" name = "openai-agents"
version = "0.0.2" version = "0.0.3"
source = { editable = "." } source = { editable = "." }
dependencies = [ dependencies = [
{ name = "griffe" }, { name = "griffe" },
@ -812,7 +812,7 @@ dev = [
[package.metadata] [package.metadata]
requires-dist = [ requires-dist = [
{ name = "griffe", specifier = ">=1.5.6,<2" }, { name = "griffe", specifier = ">=1.5.6,<2" },
{ name = "openai", specifier = ">=1.66.0" }, { name = "openai", specifier = ">=1.66.2" },
{ name = "pydantic", specifier = ">=2.10,<3" }, { name = "pydantic", specifier = ">=2.10,<3" },
{ name = "requests", specifier = ">=2.0,<3" }, { name = "requests", specifier = ">=2.0,<3" },
{ name = "types-requests", specifier = ">=2.0,<3" }, { name = "types-requests", specifier = ">=2.0,<3" },