ADR 0002: Out-of-band media loading and containment
Why agents pass scoped workspace paths instead of base64 media payloads, and how audio transcoding works safely.
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
- Path references only on MCP tools: Callers pass file paths or
file://URIs inmedia[]. Raw base64 strings are rejected by MCP inputs. - Containment and sniffing: Every path is resolved via
filepath.Absandfilepath.EvalSymlinksand verified to sit inside configuredmedia_rootsas a regular file undermax_media_bytes. Formats are sniffed from magic bytes, never extensions. - Bounded WAV transcoding: Non-WAV audio (
mp3,m4a,ogg,flac,webm) is transcoded in memory viaffmpegto 16 kHz mono 16-bit PCM WAV under a strict timeout and output byte limit, with a clear actionable error whenffmpegis 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-omniandlfm3-d1-omni/d1.2engines.
Connections
Local graphLinked from
- “ADR 0002: Out-of-band media loading and containment”
- “ADR 0002: Out-of-band media loading and containment”