@@ -64,8 +64,8 @@ def make_web_fetch(
6464 5 MiB.
6565 client: Optional ``httpx.AsyncClient`` to use for requests. When
6666 provided, the tool uses it directly and will not close it.
67- When ``None``, a new client is created per request with httpx
68- defaults .
67+ When ``None``, a new client is created per request with
68+ ``follow_redirects=True`` and httpx's default timeout (5s) .
6969 model: Optional model for the summarizer. Resolution order when
7070 ``prompt`` is non-empty: this model, then the host agent's model,
7171 then ``ValueError`` if neither is available.
@@ -88,8 +88,7 @@ async def web_fetch_tool(
8888 """Fetches an HTTP(S) URL and returns readable content.
8989
9090 Only ``http://`` and ``https://`` URLs are accepted. Raises
91- ``TimeoutError`` if the request does not complete within the
92- configured timeout.
91+ ``TimeoutError`` if the request exceeds the client's timeout.
9392
9493 Args:
9594 url: The URL to fetch. Must be ``http://`` or ``https://``.
@@ -125,8 +124,7 @@ async def web_fetch_tool(
125124 effective_model = summarizer_model or getattr (agent_obj , "model" , None )
126125 if effective_model is None :
127126 raise ValueError (
128- "web_fetch: prompt requires a model. Pass model= to make_web_fetch "
129- "or call the tool from an agent."
127+ "web_fetch: prompt requires a model. Pass model= to make_web_fetch or call the tool from an agent."
130128 )
131129 # Fresh agent per call — no history from one fetch bleeds into the next.
132130 summarizer = Agent (
@@ -180,6 +178,7 @@ async def _fetch_once(
180178 chunks : list [bytes ] = []
181179 total = 0
182180 async for chunk in response .aiter_bytes ():
181+ _check_cancelled (cancel_signal )
183182 total += len (chunk )
184183 if total > max_bytes :
185184 raise ValueError (f"Response body exceeded { max_bytes } bytes. Refusing to buffer more." )
0 commit comments