fix: raise web_read and http_fetch max_chars cap to 128K
Both tools now accept max_chars up to 131072 to accommodate long documentation pages and large API responses. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -67,7 +67,7 @@ async def http_fetch(
|
|||||||
"""
|
"""
|
||||||
method = method.upper()
|
method = method.upper()
|
||||||
timeout = min(max(int(timeout), 1), 60)
|
timeout = min(max(int(timeout), 1), 60)
|
||||||
max_chars = min(max(int(max_chars), 100), 32768)
|
max_chars = min(max(int(max_chars), 100), 131072)
|
||||||
try:
|
try:
|
||||||
async with httpx.AsyncClient(timeout=timeout, follow_redirects=True) as client:
|
async with httpx.AsyncClient(timeout=timeout, follow_redirects=True) as client:
|
||||||
resp = await client.request(method, url, content=body)
|
resp = await client.request(method, url, content=body)
|
||||||
@@ -90,7 +90,7 @@ async def web_read(url: str, max_chars: int = 16000) -> str:
|
|||||||
surrounding noise. Returns markdown-formatted output.
|
surrounding noise. Returns markdown-formatted output.
|
||||||
For raw responses (JSON APIs, health checks), use http_fetch instead.
|
For raw responses (JSON APIs, health checks), use http_fetch instead.
|
||||||
"""
|
"""
|
||||||
max_chars = min(max(int(max_chars), 1000), 32000)
|
max_chars = min(max(int(max_chars), 1000), 131072)
|
||||||
return await asyncio.to_thread(_sync_web_read, url, max_chars)
|
return await asyncio.to_thread(_sync_web_read, url, max_chars)
|
||||||
|
|
||||||
|
|
||||||
@@ -111,7 +111,7 @@ def _sync_web_read(url: str, max_chars: int) -> str:
|
|||||||
return f"Could not extract readable content from: {url}"
|
return f"Could not extract readable content from: {url}"
|
||||||
|
|
||||||
if len(text) > max_chars:
|
if len(text) > max_chars:
|
||||||
text = text[:max_chars] + f"\n\n[… truncated at {max_chars} chars — pass a larger max_chars to see more]"
|
text = text[:max_chars] + f"\n\n[… truncated at {max_chars} chars — pass a larger max_chars (up to 131072) to see more]"
|
||||||
return f"Content from {url}:\n\n{text}"
|
return f"Content from {url}:\n\n{text}"
|
||||||
|
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ DECLARATIONS = [
|
|||||||
"method": types.Schema(type=types.Type.STRING, description="HTTP method: GET (default), POST, HEAD"),
|
"method": types.Schema(type=types.Type.STRING, description="HTTP method: GET (default), POST, HEAD"),
|
||||||
"body": types.Schema(type=types.Type.STRING, description="Optional request body (for POST requests)"),
|
"body": types.Schema(type=types.Type.STRING, description="Optional request body (for POST requests)"),
|
||||||
"timeout": types.Schema(type=types.Type.INTEGER, description="Request timeout in seconds (default 15, max 60)"),
|
"timeout": types.Schema(type=types.Type.INTEGER, description="Request timeout in seconds (default 15, max 60)"),
|
||||||
"max_chars": types.Schema(type=types.Type.INTEGER, description="Max characters to return (default 8192, max 32768)"),
|
"max_chars": types.Schema(type=types.Type.INTEGER, description="Max characters to return (default 8192, max 131072)"),
|
||||||
},
|
},
|
||||||
required=["url"],
|
required=["url"],
|
||||||
),
|
),
|
||||||
@@ -164,7 +164,7 @@ DECLARATIONS = [
|
|||||||
type=types.Type.OBJECT,
|
type=types.Type.OBJECT,
|
||||||
properties={
|
properties={
|
||||||
"url": types.Schema(type=types.Type.STRING, description="Full URL to fetch and extract"),
|
"url": types.Schema(type=types.Type.STRING, description="Full URL to fetch and extract"),
|
||||||
"max_chars": types.Schema(type=types.Type.INTEGER, description="Max characters to return (default 16000, max 32000)"),
|
"max_chars": types.Schema(type=types.Type.INTEGER, description="Max characters to return (default 16000, max 131072)"),
|
||||||
},
|
},
|
||||||
required=["url"],
|
required=["url"],
|
||||||
),
|
),
|
||||||
|
|||||||
Reference in New Issue
Block a user