You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
stream remote video_analyze downloads instead of reading response.content
enforce _MAX_VIDEO_BASE64_BYTES while chunks arrive
write to a temporary .part file and replace the destination only after success
add focused coverage for declared oversize, streamed oversize, and normal chunked downloads
Context
This mirrors the recent video-download response-boundary fix pattern from OpenClaw, scoped to Hermes' video_analyze remote download path.
Duplicate Audit
gh search prs --repo NousResearch/hermes-agent "video download response cap" --state open --limit 20 returned no matches.
gh search issues --repo NousResearch/hermes-agent "video download body cap" --state open --limit 20 returned no matches.
Broad live scan of open PRs/issues containing video plus download|body|response|read|bound|cap|stream found the existing xAI video JSON response PR, but no remote video download duplicate.
Validation
uv run --extra dev python -m pytest tests\tools\test_video_analyze.py -q --basetemp .pytest-tmp-video-download-response-cap
uv run --extra dev python -m ruff check tools\vision_tools.py tests\tools\test_video_analyze.py
git diff --check
Autoreview
Not run: .agents\skills\autoreview is not present in this worktree.
trust boundary: Remote HTTP/HTTPS video_analyze inputs are downloaded into Hermes cache before being base64-encoded for the multimodal request.
source/sink/invariant: The downloader must enforce the video byte cap while reading the untrusted response, avoid materializing an oversized body through response.content, and avoid leaving a completed or reusable partial file when the stream is too large.
current-main reproduction: A run-root probe imported the current-main tools/vision_tools.py and showed the old downloader accessed response.content before rejecting a 9-byte body with an 8-byte cap.
PR-head or patch-replay validation: The GitHub PR patch replayed cleanly onto current GitHub main; the same probe imported the replayed tools/vision_tools.py, rejected the oversized body during chunk iteration, did not touch response.content, and left no destination or .part file.
positive/negative cases: The focused video tests passed, including declared oversized content, streamed oversize cleanup, normal chunked download, and adjacent local-file/video_analyze behavior; ruff and diff whitespace checks passed.
residual bypass search: I reviewed the remote video call path, redirect/final URL policy checks, temp-file replacement, and sibling video URL references and did not find another changed-path route that bypasses the streaming cap.
reviewer validation: CodeRabbit completed with no findings in the clean-pass flow.
Because the submitted branch has stale/unrelated-history setup noise, I reviewed its meaningful two-file GitHub patch replayed onto current GitHub main; that replay and the focused validation passed, but the replay by itself does not prove the submitted branch will keep merging cleanly if main moves again.
Thanks for the focused boundary fix. The premise is confirmed on current main: tools/vision_tools.py:1603 reads the entire remote response through response.content before applying _MAX_VIDEO_BASE64_BYTES, and video_analyze_tool reaches that downloader for remote URLs at tools/vision_tools.py:1674-1680.
The PR changes that path to streamed chunks with an in-loop size check and only publishes the completed file after replace(). Its added tests cover declared oversize, streamed oversize cleanup, and normal chunked output. The implementation follows existing repository streaming conventions, including httpx.AsyncClient.stream() and .part publication in tools/microsoft_graph_client.py:194-235.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
area/streamingStreaming responses: gateway delivery, provider wireP2Medium — degraded but workaround existssweeper:blast-containedSweeper blast radius: contained — one narrow path / opt-in / few userssweeper:risk-security-boundarySweeper risk: may affect sandboxing, auth, credentials, or sensitive datatool/visionVision analysis and image generationtype/securitySecurity vulnerability or hardening
4 participants
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #55027
Summary
video_analyzedownloads instead of readingresponse.content_MAX_VIDEO_BASE64_BYTESwhile chunks arrive.partfile and replace the destination only after successContext
This mirrors the recent video-download response-boundary fix pattern from OpenClaw, scoped to Hermes'
video_analyzeremote download path.Duplicate Audit
gh search prs --repo NousResearch/hermes-agent "video download response cap" --state open --limit 20returned no matches.gh search issues --repo NousResearch/hermes-agent "video download body cap" --state open --limit 20returned no matches.download|body|response|read|bound|cap|streamfound the existing xAI video JSON response PR, but no remote video download duplicate.Validation
uv run --extra dev python -m pytest tests\tools\test_video_analyze.py -q --basetemp .pytest-tmp-video-download-response-capuv run --extra dev python -m ruff check tools\vision_tools.py tests\tools\test_video_analyze.pygit diff --checkAutoreview
Not run:
.agents\skills\autoreviewis not present in this worktree.