{"record":{"id":"522b8aeeda302311","repo":"langchain-ai/deepagents","slug":"offset-seconds-must-be-0-got-offset-seconds-r","errorCode":null,"errorMessage":"offset_seconds must be >= 0, got {offset_seconds!r}","messagePattern":"offset_seconds must be >= 0, got (.+?)","errorType":"exception","errorClass":"VideoExtractionError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/middleware/_video.py","lineNumber":152,"sourceCode":"\n    Returns:\n        Interleaved content blocks: a text header introducing each frame\n        followed by a JPEG `image` content block. Raw video bytes are never\n        returned.\n\n    Raises:\n        VideoExtractionError: If PyAV cannot open the payload or the\n            requested window yields no decodable frames, or if argument\n            validation fails before opening the file.\n    \"\"\"\n    try:\n        _validate_video_window(\n            offset_seconds=offset_seconds,\n            duration_seconds=duration_seconds,\n            sampling_rate=sampling_rate,\n        )\n    except ValueError as exc:\n        raise VideoExtractionError(str(exc)) from exc\n    rate = float(sampling_rate)\n    duration = float(duration_seconds)\n\n    av = _import_av()\n    container = _open_video_container(av, content)\n    backend_error_types = _video_backend_error_types(av)\n    try:\n        try:\n            video_stream = _find_video_stream(container)\n            raw_time_base = video_stream.time_base\n            if raw_time_base is None:\n                msg = \"Video stream has no time_base; cannot determine frame timestamps\"\n                raise VideoExtractionError(msg)\n            time_base = float(raw_time_base)\n            if time_base == 0.0:\n                msg = \"Video stream time_base is zero; cannot determine frame timestamps\"\n                raise VideoExtractionError(msg)\n            stream_start_seconds = _stream_start_seconds(video_stream, time_base)","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/middleware/_video.py#L134-L170","documentation":"extract_video_frames validates the sampling window before opening the video. A negative offset_seconds is invalid (time before the start of the media), so the underlying ValueError from _validate_video_window is re-raised as VideoExtractionError.","triggerScenarios":"Calling extract_video_frames(offset_seconds=-5, ...) directly, or via a video read where the caller computed a negative offset (e.g. subtracting durations or misinterpreting 'seconds from end').","commonSituations":"LLM agents supplying negative offsets when asked to inspect the end of a clip; arithmetic errors computing window starts; UI inputs that arrive negative after conversion.","solutions":["Clamp offset_seconds to 0: max(0, offset_seconds).","Compute offsets only from guaranteed non-negative timestamps.","Validate user/agent-provided offsets before calling.","Catch VideoExtractionError and retry with offset_seconds=0."],"exampleFix":"// before\nframes = extract_video_frames(content, offset_seconds=-2.0)\n// after\nframes = extract_video_frames(content, offset_seconds=max(0.0, offset_seconds))","handlingStrategy":"validation","validationCode":"def valid_window(offset_seconds: float, duration_seconds: float, sampling_rate: float) -> bool:\n    return offset_seconds >= 0 and duration_seconds > 0 and sampling_rate > 0","typeGuard":"def is_non_negative_number(v: object) -> bool:\n    return isinstance(v, (int, float)) and not isinstance(v, bool) and v >= 0","tryCatchPattern":"try:\n    frames = extract_video_frames(content, offset_seconds=offset)\nexcept VideoExtractionError as exc:\n    if \"offset_seconds must be >= 0\" in str(exc):\n        frames = extract_video_frames(content, offset_seconds=0.0)\n    else:\n        raise","preventionTips":["Clamp offsets with max(0.0, offset) before extraction.","Reject negative numeric tool parameters at your tool-call schema layer.","Unit-test window computations so offsets can never go negative.","Treat timestamps from external sources as unsigned."],"tags":["video","validation","argument-error"],"backgroundTag":"invalid-argument-value","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}