---
type: Decision
title: "ADR 0002: Out-of-band media loading and containment"
description: Why agents pass scoped workspace paths instead of base64 media payloads, and how audio transcoding works safely.
status: stable
tags: [adr, security, media, omnimodal]
---

# ADR 0002: Out-of-band media loading and containment

## Context

Omni-modal decision models accept images, audio clips, video clips, and PDFs. Passing base64-encoded media inside MCP JSON arguments bloats the agent's context window by tens of thousands of tokens and risks arbitrary local file exfiltration if paths are not strictly bounded.

## Decision

1. **Path references only on MCP tools:** Callers pass file paths or `file://` URIs in `media[]`. Raw base64 strings are rejected by MCP inputs.
2. **Containment and sniffing:** Every path is resolved via `filepath.Abs` and `filepath.EvalSymlinks` and verified to sit inside configured `media_roots` as a regular file under `max_media_bytes`. Formats are sniffed from magic bytes, never extensions.
3. **Bounded WAV transcoding:** Non-WAV audio (`mp3`, `m4a`, `ogg`, `flac`, `webm`) is transcoded in memory via `ffmpeg` to 16 kHz mono 16-bit PCM WAV under a strict timeout and output byte limit, with a clear actionable error when `ffmpeg` is unavailable.

## Consequences

- Agent context overhead stays negligible regardless of media duration or resolution.
- Symlink traversal and non-regular device reads are blocked before any file bytes are read.
- Audio/video payloads work uniformly across `clef-omni` and `lfm3-d1-omni` / `d1.2` engines.
