iflytek/astron-agent · warning · RemoteResourcePolicyError
Remote resource is too large
Error message
Remote resource is too large
What it means
_read_bounded_response first checks the response's Content-Length header; if it exceeds max_bytes (default 50MB, DEFAULT_MAX_DOWNLOAD_BYTES), the download is rejected before any body is read. This prevents memory exhaustion from oversized remote resources.
Solutions
- If the payload is legitimately needed, pass a larger max_bytes to fetch_public_resource.
- Serve/download a smaller artifact (compressed file, thumbnail, ranged/chunked retrieval) instead.
- Verify you are not accidentally pointing at the wrong (larger) object URL.
Example fix
// before await fetch_public_resource(url) # default 50 MB cap // after await fetch_public_resource(url, max_bytes=200 * 1024 * 1024) # allow 200 MB
Defensive patterns
Strategy: validation
Validate before calling
# preflight with a HEAD request
async with aiohttp.ClientSession() as s:
async with s.head(url, allow_redirects=False) as r:
if int(r.headers.get("Content-Length", 0)) > max_bytes:
raise ValueError("file too large") Try / catch
try:
data = await fetch_public_resource(url, max_bytes=limit)
except HTTPClientException as e:
if "too large" in str(e):
... # surface a 413-style error to the user Prevention
- Check Content-Length before downloading
- Pick max_bytes deliberately per call site
- Serve thumbnails/compressed variants for previews
When it happens
Trigger: The server declares a Content-Length larger than max_bytes for the requested resource; fetch_public_resource called with a reduced max_bytes against a large file.
Common situations: Downloading large videos/archives/datasets through an API that caps downloads at 50MB; caller lowered max_bytes to e.g. 1MB while the file is bigger; object URL points at a full archive rather than a thumbnail.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
- KNOWLEDGE_REQUEST_ERROR
- MCP_REQUEST_ERROR
- Remote resource returned HTTP
- REPO_KNOWLEDGE_DOWNLOAD_FAILED
- Skill resource download failed: HTTP
AI-assisted analysis of iflytek/astron-agent@5e758547a8 (2026-09-12).
Data as JSON: /api/errors/6005ef35de565c72.
Report an issue: GitHub.
Appendix: source
Thrown at core/plugin/aitools/common/clients/safe_download.py:152
connector=connector,
timeout=timeout,
trust_env=False,
) as session:
async with session.get(url, allow_redirects=False) as response:
if not 200 <= response.status < 300:
raise RemoteResourcePolicyError(
f"Remote resource returned HTTP {response.status}"
)
return await _read_bounded_response(response, max_bytes)
async def _read_bounded_response(
response: aiohttp.ClientResponse,
max_bytes: int,
) -> bytes:
content_length = response.content_length
if content_length is not None and content_length > max_bytes:
raise RemoteResourcePolicyError("Remote resource is too large")
content = bytearray()
async for chunk in response.content.iter_chunked(_DOWNLOAD_CHUNK_SIZE):
if len(content) + len(chunk) > max_bytes:
raise RemoteResourcePolicyError("Remote resource is too large")
content.extend(chunk)
return bytes(content)
def _validate_resource_url(url: str) -> Tuple[SplitResult, bool]:
parsed = _parse_resource_url(url)
allow_private_storage = _is_configured_storage_url(parsed)
normalized_host = _normalize_hostname(parsed.hostname or "")
literal_address = _parse_ip(normalized_host)
if literal_address is not None:
_validate_destination_address(
literal_address,
allow_private_storage=allow_private_storage,View on GitHub (pinned to 5e758547a8)