Skip to content

Commit 281a7b2

Browse files
adopted float instead of timedelta for timeout parameters (#874)
I replaced the `timedelta` parameters for MCP timeouts with `float` values, addressing issue #845 . Given that the MCP official repository has incorporated these changes in [this PR](modelcontextprotocol/python-sdk#941), updating the MCP version in openai-agents and specifying the timeouts as floats should be enough.
1 parent 6d2806f commit 281a7b2

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies = [
1313
"typing-extensions>=4.12.2, <5",
1414
"requests>=2.0, <3",
1515
"types-requests>=2.0, <3",
16-
"mcp>=1.8.0, <2; python_version >= '3.10'",
16+
"mcp>=1.9.4, <2; python_version >= '3.10'",
1717
]
1818
classifiers = [
1919
"Typing :: Typed",

src/agents/mcp/server.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,10 +340,10 @@ class MCPServerStreamableHttpParams(TypedDict):
340340
headers: NotRequired[dict[str, str]]
341341
"""The headers to send to the server."""
342342

343-
timeout: NotRequired[timedelta]
343+
timeout: NotRequired[timedelta | float]
344344
"""The timeout for the HTTP request. Defaults to 5 seconds."""
345345

346-
sse_read_timeout: NotRequired[timedelta]
346+
sse_read_timeout: NotRequired[timedelta | float]
347347
"""The timeout for the SSE connection, in seconds. Defaults to 5 minutes."""
348348

349349
terminate_on_close: NotRequired[bool]
@@ -401,8 +401,8 @@ def create_streams(
401401
return streamablehttp_client(
402402
url=self.params["url"],
403403
headers=self.params.get("headers", None),
404-
timeout=self.params.get("timeout", timedelta(seconds=30)),
405-
sse_read_timeout=self.params.get("sse_read_timeout", timedelta(seconds=60 * 5)),
404+
timeout=self.params.get("timeout", 5),
405+
sse_read_timeout=self.params.get("sse_read_timeout", 60 * 5),
406406
terminate_on_close=self.params.get("terminate_on_close", True),
407407
)
408408

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)