Skip to content

Commit 59a8116

Browse files
committed
fix
1 parent f6f1576 commit 59a8116

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/agents/models/chatcmpl_converter.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,20 @@
4444
from ..exceptions import AgentsException, UserError
4545
from ..handoffs import Handoff
4646
from ..items import TResponseInputItem, TResponseOutputItem
47+
from ..model_settings import MCPToolChoice
4748
from ..tool import FunctionTool, Tool
4849
from .fake_id import FAKE_RESPONSES_ID
4950

5051

5152
class Converter:
5253
@classmethod
5354
def convert_tool_choice(
54-
cls, tool_choice: Literal["auto", "required", "none"] | str | None
55+
cls, tool_choice: Literal["auto", "required", "none"] | str | MCPToolChoice | None
5556
) -> ChatCompletionToolChoiceOptionParam | NotGiven:
5657
if tool_choice is None:
5758
return NOT_GIVEN
59+
elif isinstance(tool_choice, MCPToolChoice):
60+
raise UserError("MCPToolChoice is not supported for Chat Completions models")
5861
elif tool_choice == "auto":
5962
return "auto"
6063
elif tool_choice == "required":

src/agents/models/openai_responses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ def convert_tool_choice(
343343
elif tool_choice == "mcp":
344344
# Note that this is still here for backwards compatibility,
345345
# but migrating to MCPToolChoice is recommended.
346-
return { "type": "mcp" }
346+
return { "type": "mcp" } # type: ignore [typeddict-item]
347347
else:
348348
return {
349349
"type": "function",

0 commit comments

Comments
 (0)