When to reach for it
- Agents process multimodal data.
- Media content carries compliance or security risks.
- Outputs in multiple modalities must be controlled.
Per-modality filters on every input and output the agent touches.
Text, image, audio, or video inputs and outputs are screened by modality-specific safety classifiers on the way in and on the way out, since a text-only filter is blind to harmful content encoded in other modalities.
In practiceA social-media moderation agent passes every uploaded image through an image-specific content safety classifier before the vision model processes it, blocking unsafe images the text guardrail would never see.
Without itWithout modality-specific guardrails, harmful content encoded in images, audio, or video reaches the model unchecked while text-only safety filters report no violations. See the anti-pattern →
Each kind of content gets a classifier that can actually read it. An image goes to an image classifier and audio to an audio classifier, on the way in and again on the way out.
1 · On the way in
2 · On the way out
| Upload | Text filter | Image check | Outcome |
|---|---|---|---|
| A holiday photo, caption “great trip” | Passes | Passes | Processed |
| A violent image, caption “look at this” | Passes | Blocks: violence | Blocked before the vision model |
| A screenshot of text with instructions to the model | Sees no text | Flags embedded text | The text is extracted and treated as untrusted |
| A harmless photo, abusive caption | Blocks: harassment | Passes | Blocked |
CLASSIFIERS = {"text": text_safety, "image": image_safety, "audio": audio_safety}
THRESHOLD = 0.8
def screen(parts):
"""parts: a list of (modality, content). Returns the first violation, or None."""
for modality, content in parts:
# the classifier that can read this content
verdict = CLASSIFIERS[modality](content)
if verdict.score >= THRESHOLD:
return modality, verdict.category
return None
def guarded(parts):
blocked = screen(parts) # on the way in
if blocked:
return refusal(*blocked)
output = model(parts)
blocked = screen(output.parts) # and on the way out
return refusal(*blocked) if blocked else outputWhen to reach for it
When it backfires
A text safety filter is applied to an OCR'd image caption. The harmful content was in the image itself, not the caption — the modality boundary was crossed without a matching filter.
Countermeasure
Mandate a modality-specific filter at every modality transition. Treat 'text filter applied to image' as a configuration error the validator can detect.
A guardrail checks uploaded media on the way in, but the model's own generated image or audio leaves unchecked — so the system can produce exactly the unsafe content it refuses to accept.
Countermeasure
Apply rails on both paths: classify inputs before the model and outputs before delivery (the Llama Guard input/output pattern), per modality.
Keep going
Search patterns, frameworks, and pages.