langchain-ai/deepagents · error · ValueError
duration_seconds must be > 0, got {duration_seconds!r}
Error message
duration_seconds must be > 0, got {duration_seconds!r} What it means
`_validate_video_window` requires `duration_seconds` to be strictly positive. A zero or negative window length is meaningless (no frames could be sampled), so the call is rejected with ValueError before opening the video.
Source
Thrown at libs/deepagents/deepagents/middleware/_video.py:212
if not blocks:
end_seconds = offset_seconds + duration
msg = f"No frames decoded for window [{offset_seconds:.3f}s, {end_seconds:.3f}s)"
raise VideoExtractionError(msg)
return blocks
def _validate_video_window(*, offset_seconds: float, duration_seconds: float, sampling_rate: float) -> None:
"""Validate the requested sampling window before opening the video."""
if offset_seconds < 0:
msg = f"offset_seconds must be >= 0, got {offset_seconds!r}"
raise ValueError(msg)
if sampling_rate <= 0:
msg = f"sampling_rate must be > 0, got {sampling_rate!r}"
raise ValueError(msg)
if duration_seconds <= 0:
msg = f"duration_seconds must be > 0, got {duration_seconds!r}"
raise ValueError(msg)
def _open_video_container(av: Any, content: bytes) -> Any: # noqa: ANN401 # PyAV types are unavailable without the [video] extra
"""Open a video byte payload, normalizing PyAV's failure modes.
PyAV typically raises `av.error.InvalidDataError` for malformed inputs,
but it falls back to `OSError` when the system ffmpeg library is missing
or incompatible. Both surface to callers as `VideoExtractionError` so
the middleware does not have to distinguish between them.
"""
try:
return av.open(io.BytesIO(content))
except _video_backend_error_types(av) as exc: # pragma: no cover - depends on host/input
msg = f"Failed to open video payload: {exc}"
raise VideoExtractionError(msg) from exc
def _video_backend_error_types(av: Any) -> tuple[type[BaseException], ...]: # noqa: ANN401 # PyAV types are unavailable without the [video] extraView on GitHub (pinned to a1af029e6e)
Solutions
- Pass a positive `duration_seconds`
- Fix the start/end computation so end > start
- If you want the remainder of the video, use a duration at least as large as the remaining length
Example fix
// before
duration = segment_end - segment_start # segment_end <= segment_start
extract_video_frames(content, offset_seconds=segment_start, duration_seconds=duration)
// after
duration = max(0.0, segment_end - segment_start)
if duration <= 0:
return # empty segment, nothing to sample
extract_video_frames(content, offset_seconds=segment_start, duration_seconds=duration) Defensive patterns
Strategy: validation
Validate before calling
if duration_seconds <= 0:
raise ValueError(f"duration_seconds must be > 0, got {duration_seconds!r}") Type guard
def is_valid_duration(duration_seconds: float) -> bool:
return isinstance(duration_seconds, (int, float)) and duration_seconds > 0 Prevention
- Ensure end timestamps are strictly greater than start timestamps
- Skip empty segments before requesting extraction
- Don't pass 0 expecting 'whole video'; pass an explicit positive duration
When it happens
Trigger: Calling `extract_video_frames` with `duration_seconds=0` or negative, e.g. `end - start` where end <= start.
Common situations: Slicing logic where the computed window is empty; passing 0 expecting 'to the end'; timestamp pairs out of order.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- sampling_rate must be > 0, got {sampling_rate!r}
- modes can only be provided when agent is a factory
- models can only be provided when agent is a factory
- -32602
- recursion_limit must be None or a positive integer
AI-assisted analysis of langchain-ai/deepagents@a1af029e6e (2026-08-29).
Data as JSON: /api/errors/d43471252ac6c138.
Report an issue: GitHub.