Skip to content

chore(deps): Bump "openai>=1.99.6,<2" #1415

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 4 commits into from
Aug 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
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ requires-python = ">=3.9"
license = "MIT"
authors = [{ name = "OpenAI", email = "[email protected]" }]
dependencies = [
"openai>=1.97.1,<2",
"openai>=1.99.6,<2",
"pydantic>=2.10, <3",
"griffe>=1.5.6, <2",
"typing-extensions>=4.12.2, <5",
Expand Down
17 changes: 11 additions & 6 deletions src/agents/extensions/models/litellm_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,17 @@
) from _e

from openai import NOT_GIVEN, AsyncStream, NotGiven
from openai.types.chat import ChatCompletionChunk, ChatCompletionMessageToolCall
from openai.types.chat import (
ChatCompletionChunk,
ChatCompletionMessageFunctionToolCall,
)
from openai.types.chat.chat_completion_message import (
Annotation,
AnnotationURLCitation,
ChatCompletionMessage,
)
from openai.types.chat.chat_completion_message_tool_call import Function
from openai.types.chat.chat_completion_message_function_tool_call import Function
from openai.types.chat.chat_completion_message_tool_call import ChatCompletionMessageToolCall
from openai.types.responses import Response

from ... import _debug
Expand Down Expand Up @@ -362,7 +366,7 @@ def convert_message_to_openai(
if message.role != "assistant":
raise ModelBehaviorError(f"Unsupported role: {message.role}")

tool_calls = (
tool_calls: list[ChatCompletionMessageToolCall] | None = (
[LitellmConverter.convert_tool_call_to_openai(tool) for tool in message.tool_calls]
if message.tool_calls
else None
Expand Down Expand Up @@ -413,11 +417,12 @@ def convert_annotations_to_openai(
@classmethod
def convert_tool_call_to_openai(
cls, tool_call: litellm.types.utils.ChatCompletionMessageToolCall
) -> ChatCompletionMessageToolCall:
return ChatCompletionMessageToolCall(
) -> ChatCompletionMessageFunctionToolCall:
return ChatCompletionMessageFunctionToolCall(
id=tool_call.id,
type="function",
function=Function(
name=tool_call.function.name or "", arguments=tool_call.function.arguments
name=tool_call.function.name or "",
arguments=tool_call.function.arguments,
),
)
25 changes: 14 additions & 11 deletions src/agents/models/chatcmpl_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
ChatCompletionContentPartTextParam,
ChatCompletionDeveloperMessageParam,
ChatCompletionMessage,
ChatCompletionMessageFunctionToolCallParam,
ChatCompletionMessageParam,
ChatCompletionMessageToolCallParam,
ChatCompletionSystemMessageParam,
ChatCompletionToolChoiceOptionParam,
ChatCompletionToolMessageParam,
Expand Down Expand Up @@ -126,15 +126,18 @@ def message_to_output_items(cls, message: ChatCompletionMessage) -> list[TRespon

if message.tool_calls:
for tool_call in message.tool_calls:
items.append(
ResponseFunctionToolCall(
id=FAKE_RESPONSES_ID,
call_id=tool_call.id,
arguments=tool_call.function.arguments,
name=tool_call.function.name,
type="function_call",
if tool_call.type == "function":
items.append(
ResponseFunctionToolCall(
id=FAKE_RESPONSES_ID,
call_id=tool_call.id,
arguments=tool_call.function.arguments,
name=tool_call.function.name,
type="function_call",
)
)
)
elif tool_call.type == "custom":
pass

return items

Expand Down Expand Up @@ -420,7 +423,7 @@ def ensure_assistant_message() -> ChatCompletionAssistantMessageParam:
elif file_search := cls.maybe_file_search_call(item):
asst = ensure_assistant_message()
tool_calls = list(asst.get("tool_calls", []))
new_tool_call = ChatCompletionMessageToolCallParam(
new_tool_call = ChatCompletionMessageFunctionToolCallParam(
id=file_search["id"],
type="function",
function={
Expand All @@ -440,7 +443,7 @@ def ensure_assistant_message() -> ChatCompletionAssistantMessageParam:
asst = ensure_assistant_message()
tool_calls = list(asst.get("tool_calls", []))
arguments = func_call["arguments"] if func_call["arguments"] else "{}"
new_tool_call = ChatCompletionMessageToolCallParam(
new_tool_call = ChatCompletionMessageFunctionToolCallParam(
id=func_call["call_id"],
type="function",
function={
Expand Down
6 changes: 3 additions & 3 deletions tests/test_openai_chatcompletions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
from openai.types.chat.chat_completion import ChatCompletion, Choice
from openai.types.chat.chat_completion_chunk import ChatCompletionChunk
from openai.types.chat.chat_completion_message import ChatCompletionMessage
from openai.types.chat.chat_completion_message_tool_call import (
ChatCompletionMessageToolCall,
from openai.types.chat.chat_completion_message_tool_call import ( # type: ignore[attr-defined]
ChatCompletionMessageFunctionToolCall,
Function,
)
from openai.types.completion_usage import (
Expand Down Expand Up @@ -152,7 +152,7 @@ async def test_get_response_with_tool_call(monkeypatch) -> None:
should append corresponding `ResponseFunctionToolCall` items after the
assistant message item with matching name/arguments.
"""
tool_call = ChatCompletionMessageToolCall(
tool_call = ChatCompletionMessageFunctionToolCall(
id="call-id",
type="function",
function=Function(name="do_thing", arguments="{'x':1}"),
Expand Down
10 changes: 5 additions & 5 deletions tests/test_openai_chatcompletions_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
from typing import Literal, cast

import pytest
from openai.types.chat import ChatCompletionMessage, ChatCompletionMessageToolCall
from openai.types.chat import ChatCompletionMessage, ChatCompletionMessageFunctionToolCall
from openai.types.chat.chat_completion_message_tool_call import Function
from openai.types.responses import (
ResponseFunctionToolCall,
Expand Down Expand Up @@ -87,7 +87,7 @@ def test_message_to_output_items_with_tool_call():
be reflected as separate `ResponseFunctionToolCall` items appended after
the message item.
"""
tool_call = ChatCompletionMessageToolCall(
tool_call = ChatCompletionMessageFunctionToolCall(
id="tool1",
type="function",
function=Function(name="myfn", arguments='{"x":1}'),
Expand Down Expand Up @@ -185,7 +185,7 @@ def test_items_to_messages_with_output_message_and_function_call():
# Refusal in output message should be represented in assistant message
assert "refusal" in assistant
assert assistant["refusal"] == refusal.refusal
# Tool calls list should contain one ChatCompletionMessageToolCall dict
# Tool calls list should contain one ChatCompletionMessageFunctionToolCall dict
tool_calls = assistant.get("tool_calls")
assert isinstance(tool_calls, list)
assert len(tool_calls) == 1
Expand Down Expand Up @@ -341,8 +341,8 @@ def test_tool_call_conversion():

tool_call = tool_calls[0]
assert tool_call["id"] == function_call["call_id"]
assert tool_call["function"]["name"] == function_call["name"]
assert tool_call["function"]["arguments"] == function_call["arguments"]
assert tool_call["function"]["name"] == function_call["name"] # type: ignore
assert tool_call["function"]["arguments"] == function_call["arguments"] # type: ignore


@pytest.mark.parametrize("role", ["user", "system", "developer"])
Expand Down
8 changes: 4 additions & 4 deletions uv.lock

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