NousResearch/hermes-agent · warning · ValueError
Video at {url} exceeds {max_bytes // (1024 * 1024)}MB cap; r
Error message
Video at {url} exceeds {max_bytes // (1024 * 1024)}MB cap; refusing to cache. What it means
ValueError from the video caching download loop in agent/video_gen_provider.py:310. The provider streams a generated video to disk in 256KB chunks and enforces a hard byte cap; if the running total exceeds max_bytes the partial file is closed, unlinked, and this error raised. It protects the cache directory from unbounded writes.
Source
Thrown at agent/video_gen_provider.py:310
extension = "mp4"
ts = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
short = uuid.uuid4().hex[:8]
path = _videos_cache_dir() / f"{prefix}_{ts}_{short}.{extension}"
bytes_written = 0
with path.open("wb") as fh:
for chunk in response.iter_content(chunk_size=256 * 1024):
if not chunk:
continue
bytes_written += len(chunk)
if bytes_written > max_bytes:
fh.close()
try:
path.unlink()
except OSError:
pass
raise ValueError(
f"Video at {url} exceeds {max_bytes // (1024 * 1024)}MB cap; refusing to cache."
)
fh.write(chunk)
if bytes_written == 0:
try:
path.unlink()
except OSError:
pass
raise ValueError(f"Video at {url} was empty (0 bytes).")
return path
def success_response(
*,
video: str,
model: str,View on GitHub (pinned to c896c09c42)
Solutions
- Raise the max_bytes cap for the provider if the larger video is expected and disk space allows.
- Request a smaller output (shorter duration / lower resolution) from the video provider.
- Check the URL actually points at the intended asset — a wrong URL (e.g. an HTML page behind a redirect) can also inflate size; verify with curl -I.
Example fix
# before provider._max_cache_bytes = 50 * 1024 * 1024 # 50MB, video is 120MB # after provider._max_cache_bytes = 256 * 1024 * 1024 # raise cap to fit expected output
Defensive patterns
Strategy: validation
Validate before calling
import urllib.request
def video_fits_cap(url: str, max_bytes: int) -> bool:
try:
size = int(urllib.request.urlopen(urllib.request.Request(url, method="HEAD")).headers["Content-Length"])
except (KeyError, OSError):
return True # unknown; let the streaming cap decide
return size <= max_bytes Try / catch
try:
path = cache_video(url, max_bytes)
except ValueError as exc:
if "exceeds" in str(exc):
raise QuotaError("increase max_bytes or request a smaller video") from exc
raise Prevention
- Size the cache cap to the largest duration/resolution you request.
- HEAD-check Content-Length before downloading when the provider supplies it.
- Monitor cache directory usage so caps and disk stay aligned.
When it happens
Trigger: Downloading a generated video whose size exceeds the configured cap — long-duration / high-resolution generations, a provider returning the wrong (larger) asset, or a misconfigured max_bytes set lower than the provider's typical output.
Common situations: User raises resolution/duration without raising the cap; provider default sizes grow after an API change; the cap is read from config that was never set for this provider.
Related errors
- Image at {url} exceeds {max_bytes // (1024 * 1024)}MB cap; r
- Video at {url} was empty (0 bytes).
- Content too large
- Could not fetch image: ${response.status}
- image too large (max ${mb} MB)
AI-assisted analysis of NousResearch/hermes-agent@c896c09c42 (2026-08-14).
Data as JSON: /api/errors/f936c5cb9a221f19.
Report an issue: GitHub.