Panniantong/Agent-Reach · error · TranscribeError

{label} exceeds safety limit of {limit_mib:g} MiB

Error message

{label} exceeds safety limit of {limit_mib:g} MiB

What it means

Raised by _require_size_at_most() in agent_reach/transcribe.py when an input media file's on-disk size exceeds the configured safety limit. The check runs before any expensive processing so an oversized upload fails immediately. The limit is formatted in MiB in the message (label identifies which artifact — input or chunk — was too large).

Source

Thrown at agent_reach/transcribe.py:88


_BLOCKED_HOSTS = {
    "localhost",
    "metadata.google.internal",
}


def _require(binary: str) -> None:
    if not shutil.which(binary):
        raise MissingDependency(f"{binary} not found in PATH")


def _require_size_at_most(path: Path, limit: int, label: str) -> int:
    """Return file size or fail before expensive downstream processing."""
    size = path.stat().st_size
    if size > limit:
        limit_mib = limit / (1024 * 1024)
        raise TranscribeError(f"{label} exceeds safety limit of {limit_mib:g} MiB")
    return size


def _probe_audio_duration(path: Path) -> float:
    """Return duration in seconds or fail closed before media generation."""
    _require("ffprobe")
    cmd = [
        "ffprobe",
        "-v",
        "error",
        "-show_entries",
        "format=duration",
        "-of",
        "default=noprint_wrappers=1:nokey=1",
        "-i",
        str(path),
    ]
    try:

View on GitHub (pinned to 93ae1d18c3)

Solutions

  1. Compress or downsample the media first (e.g. ffmpeg -i in.mp3 -b:a 48k out.m4a) to get under the limit
  2. Trim the file into smaller segments and transcribe each separately
  3. Read the message's MiB figure and check your file with `ls -l` or os.path.getsize before retrying

Example fix

# before
transcribe_audio(Path('huge_recording.wav'))  # exceeds safety limit

# after: compress first
subprocess.run(['ffmpeg', '-i', 'huge_recording.wav', '-b:a', '48k', 'small.m4a'])
transcribe_audio(Path('small.m4a'))
Defensive patterns

Strategy: validation

Validate before calling

size = path.stat().st_size
if size > MAX_MEDIA_BYTES:  # mirror the module's limit
    raise ValueError(f'{path} is {size/2**20:.0f} MiB; compress or split first')

Type guard

def within_size_limit(path, limit: int) -> bool:
    return path.stat().st_size <= limit

Try / catch

from agent_reach.transcribe import TranscribeError
try:
    transcribe_audio(path)
except TranscribeError as e:
    if 'safety limit' in str(e):
        compress(path)  # ffmpeg -b:a 48k, then retry once
    else:
        raise

Prevention

When it happens

Trigger: Passing a multi-hundred-MB audio/video file to the transcribe pipeline; regenerated chunks or concatenated media exceeding the byte cap during processing.

Common situations: Transcribing long downloads (podcast archives, multi-hour streams) without pre-compression; disk-full conditions during chunking inflating partial files.

Related errors


AI-assisted analysis of Panniantong/Agent-Reach@93ae1d18c3 (2026-08-14). Data as JSON: /api/errors/eb57926012450653. Report an issue: GitHub.