Skip to content
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

Bump open AI sdk version #32

Merged
merged 2 commits into from
Mar 11, 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
7 changes: 4 additions & 3 deletions examples/tools/computer_use.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import asyncio
import base64
import logging
from typing import Literal, Union

from playwright.async_api import Browser, Page, Playwright, async_playwright
Expand All @@ -16,8 +15,10 @@
trace,
)

logging.getLogger("openai.agents").setLevel(logging.DEBUG)
logging.getLogger("openai.agents").addHandler(logging.StreamHandler())
# Uncomment to see very verbose logs
# import logging
# logging.getLogger("openai.agents").setLevel(logging.DEBUG)
# logging.getLogger("openai.agents").addHandler(logging.StreamHandler())


async def main():
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "openai-agents"
version = "0.0.2"
version = "0.0.3"
description = "OpenAI Agents SDK"
readme = "README.md"
requires-python = ">=3.9"
Expand All @@ -9,7 +9,7 @@ authors = [
{ name = "OpenAI", email = "[email protected]" },
]
dependencies = [
"openai>=1.66.0",
"openai>=1.66.2",
"pydantic>=2.10, <3",
"griffe>=1.5.6, <2",
"typing-extensions>=4.12.2, <5",
Expand Down
4 changes: 2 additions & 2 deletions src/agents/_run_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
ActionWait,
)
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 .agent import Agent
Expand Down Expand Up @@ -288,7 +288,7 @@ def process_model_response(
items.append(ToolCallItem(raw_item=output, agent=agent))
elif isinstance(output, ResponseFunctionWebSearch):
items.append(ToolCallItem(raw_item=output, agent=agent))
elif isinstance(output, Reasoning):
elif isinstance(output, ResponseReasoningItem):
items.append(ReasoningItem(raw_item=output, agent=agent))
elif isinstance(output, ResponseComputerToolCall):
items.append(ToolCallItem(raw_item=output, agent=agent))
Expand Down
6 changes: 3 additions & 3 deletions src/agents/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ResponseStreamEvent,
)
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 typing_extensions import TypeAlias

Expand Down Expand Up @@ -136,10 +136,10 @@ class ToolCallOutputItem(RunItemBase[Union[FunctionCallOutput, ComputerCallOutpu


@dataclass
class ReasoningItem(RunItemBase[Reasoning]):
class ReasoningItem(RunItemBase[ResponseReasoningItem]):
"""Represents a reasoning item."""

raw_item: Reasoning
raw_item: ResponseReasoningItem
"""The raw reasoning item."""

type: Literal["reasoning_item"] = "reasoning_item"
Expand Down
2 changes: 1 addition & 1 deletion src/agents/models/openai_responses.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def _convert_tool(cls, tool: Tool) -> tuple[ToolParam, IncludeLiteral | None]:
includes = "file_search_call.results" if tool.include_search_results else None
elif isinstance(tool, ComputerTool):
converted_tool = {
"type": "computer-preview",
"type": "computer_use_preview",
"environment": tool.computer.environment,
"display_width": tool.computer.dimensions[0],
"display_height": tool.computer.dimensions[1],
Expand Down
2 changes: 2 additions & 0 deletions src/agents/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,3 +284,5 @@ def decorator(real_func: ToolFunction[...]) -> FunctionTool:
return _create_function_tool(real_func)

return decorator
return decorator
return decorator
16 changes: 9 additions & 7 deletions tests/test_items_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@
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_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_param import ResponseOutputMessageParam
from openai.types.responses.response_output_refusal import ResponseOutputRefusal
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 (
Agent,
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_text_message_outputs_across_list_of_runitems() -> None:
item1: RunItem = MessageOutputItem(agent=Agent(name="test"), raw_item=message1)
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.
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)
# Confirm only the message outputs are concatenated.
assert ItemHelpers.text_message_outputs([item1, non_message_item, item2]) == "foobar"
Expand Down Expand Up @@ -266,16 +266,18 @@ def test_to_input_items_for_computer_call_click() -> None:

def test_to_input_items_for_reasoning() -> None:
"""A reasoning output should produce the same dict as a reasoning input item."""
rc = ReasoningContent(text="why", type="reasoning_summary")
reasoning = Reasoning(id="rid1", content=[rc], type="reasoning")
rc = Summary(text="why", type="summary_text")
reasoning = ResponseReasoningItem(id="rid1", summary=[rc], type="reasoning")
resp = ModelResponse(output=[reasoning], usage=Usage(), referenceable_id=None)
input_items = resp.to_input_items()
assert isinstance(input_items, list) and len(input_items) == 1
converted_dict = input_items[0]

expected: ReasoningInputParam = {
expected: ResponseReasoningItemParam = {
"id": "rid1",
"content": [{"text": "why", "type": "reasoning_summary"}],
"summary": [{"text": "why", "type": "summary_text"}],
"type": "reasoning",
}
print(converted_dict)
print(expected)
assert converted_dict == expected
4 changes: 2 additions & 2 deletions tests/test_openai_responses_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def drag(self, path: list[tuple[int, int]]) -> None:
assert "function" in types
assert "file_search" 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
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
Expand All @@ -173,7 +173,7 @@ def drag(self, path: list[tuple[int, int]]) -> None:
assert web_params.get("user_location") == web_tool.user_location
assert web_params.get("search_context_size") == web_tool.search_context_size
# 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("display_width") == 800
assert comp_params.get("display_height") == 600
Expand Down
6 changes: 3 additions & 3 deletions tests/test_run_step_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
ResponseFunctionWebSearch,
)
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 agents import (
Expand Down Expand Up @@ -287,8 +287,8 @@ def test_function_web_search_tool_call_parsed_correctly():
def test_reasoning_item_parsed_correctly():
# Verify that a Reasoning output item is converted into a ReasoningItem.

reasoning = Reasoning(
id="r1", type="reasoning", content=[ReasoningContent(text="why", type="reasoning_summary")]
reasoning = ResponseReasoningItem(
id="r1", type="reasoning", summary=[Summary(text="why", type="summary_text")]
)
response = ModelResponse(
output=[reasoning],
Expand Down
10 changes: 5 additions & 5 deletions uv.lock

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