[BUG] http_request accepts NaN and infinite timeout values

Author: anilreddy89Created Sep 8, 2026Updated Sep 23, 2026
Labelsbugpythonarea-tool

Checks

  • I have updated to the latest minor and patch version of Strands
  • I have checked the documentation and this is not expected behavior
  • I have searched the issues and pull requests and found no duplicate

SDK Language

Python

Strands Version

Current main at 42e5a61bd98c3caf6b21c2f2e69a8bbd58eb7562 (0.1.dev1+g42e5a61bd)

Language Runtime Version

Python 3.11.14

Operating System

macOS 26.6.2

Installation Method

git clone

Steps to Reproduce

Run the following against the current Python SDK:

python
import asyncio
import math

import httpx

from strands.vended_tools.http_request.http_request import make_http_request


async def main():
    async def handler(request: httpx.Request) -> httpx.Response:
        print(request.extensions["timeout"])
        return httpx.Response(200, text="ok")

    client = httpx.AsyncClient(
        transport=httpx.MockTransport(handler),
        timeout=None,
    )
    try:
        tool = make_http_request(client=client)
        for timeout in (math.nan, math.inf):
            result = await tool(
                method="GET",
                url="https://example.com",
                timeout=timeout,
            )
            print(timeout, result["status"])
    finally:
        await client.aclose()


asyncio.run(main())

Output:

{'connect': nan, 'read': nan, 'write': nan, 'pool': nan}
nan 200
{'connect': inf, 'read': inf, 'write': inf, 'pool': inf}
inf 200

Expected Behavior

The HTTP request tool should reject non-finite timeout values before making the request, just as it rejects zero and negative values. A timeout should be finite and greater than zero.

Actual Behavior

math.nan and math.inf pass validation and are forwarded to all four HTTPX timeout phases (connect, read, write, and pool). This can silently defeat the intended timeout cap or produce transport-dependent behavior.

Additional Context

_resolve_timeout() currently checks only model_timeout <= 0. That comparison is false for NaN, while positive infinity also passes. The vendored sleep tool already uses math.isfinite() when validating its duration, so applying the same constraint here would make timeout handling consistent.

Possible Solution

Validate model_timeout with math.isfinite() in addition to the existing positive-value check, and add regression cases for NaN, positive infinity, and negative infinity.

Related Issues

None found.

Source: strands-agents/harness-sdk