{"record":{"id":"f936c5cb9a221f19","repo":"NousResearch/hermes-agent","slug":"video-at-url-exceeds-max-bytes-1024-1024","errorCode":null,"errorMessage":"Video at {url} exceeds {max_bytes // (1024 * 1024)}MB cap; refusing to cache.","messagePattern":"Video at (.+?) exceeds (.+?)MB cap; refusing to cache\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"warning","filePath":"agent/video_gen_provider.py","lineNumber":310,"sourceCode":"        extension = \"mp4\"\n\n    ts = datetime.datetime.now().strftime(\"%Y%m%d_%H%M%S\")\n    short = uuid.uuid4().hex[:8]\n    path = _videos_cache_dir() / f\"{prefix}_{ts}_{short}.{extension}\"\n\n    bytes_written = 0\n    with path.open(\"wb\") as fh:\n        for chunk in response.iter_content(chunk_size=256 * 1024):\n            if not chunk:\n                continue\n            bytes_written += len(chunk)\n            if bytes_written > max_bytes:\n                fh.close()\n                try:\n                    path.unlink()\n                except OSError:\n                    pass\n                raise ValueError(\n                    f\"Video at {url} exceeds {max_bytes // (1024 * 1024)}MB cap; refusing to cache.\"\n                )\n            fh.write(chunk)\n\n    if bytes_written == 0:\n        try:\n            path.unlink()\n        except OSError:\n            pass\n        raise ValueError(f\"Video at {url} was empty (0 bytes).\")\n\n    return path\n\n\ndef success_response(\n    *,\n    video: str,\n    model: str,","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/NousResearch/hermes-agent/blob/c896c09c42910c584c4c7d2325b58c14713ea42c/agent/video_gen_provider.py#L292-L328","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nprovider._max_cache_bytes = 50 * 1024 * 1024  # 50MB, video is 120MB\n\n# after\nprovider._max_cache_bytes = 256 * 1024 * 1024  # raise cap to fit expected output","handlingStrategy":"validation","validationCode":"import urllib.request\n\ndef video_fits_cap(url: str, max_bytes: int) -> bool:\n    try:\n        size = int(urllib.request.urlopen(urllib.request.Request(url, method=\"HEAD\")).headers[\"Content-Length\"])\n    except (KeyError, OSError):\n        return True  # unknown; let the streaming cap decide\n    return size <= max_bytes","typeGuard":null,"tryCatchPattern":"try:\n    path = cache_video(url, max_bytes)\nexcept ValueError as exc:\n    if \"exceeds\" in str(exc):\n        raise QuotaError(\"increase max_bytes or request a smaller video\") from exc\n    raise","preventionTips":["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."],"tags":["video","download","size-limit","cache"],"backgroundTag":null,"analyzedSha":"c896c09c42910c584c4c7d2325b58c14713ea42c","analyzedAt":"2026-08-14T17:18:01.089Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}