Restricting What Leaves the Machine

An agent with adk-vision reads, detects and describes images out of the box: with no .adk/vision.toml, an image a remote backend is called with leaves as the agent sends it, unredacted and unasked, to a public host or to a model on a private network, and its release is still recorded. Every restriction below is an opt-in. Once chosen, it is enforced on every path the framework controls — the vision tools release images only through the egress gate, and ImagePrivacyGuardrail runs the same gate on model requests, tool results and user input — and it fails closed: an image it holds, refuses or cannot redact never leaves (spec 3.7 §7.8, §9, §13 Q1 revised 2026-11-25).

[dependencies]
adk-vision = { version = "3.0.0", features = ["guardrail"] }

The Opt-Ins

RestrictionSet withWhat it does
Askdefault = "ask", or a rule with action = "ask"Holds the release until a person approves the exact redacted image, by its egress digest
Denydefault = "deny", or a rule with action = "deny"Refuses the release and records why
Per destination[[egress.rule]] with host (*.example.com for subdomains) or provider (anthropic, gemini, bedrock, nvidia)Applies the rule's action to that host, or to every host of that provider
Redactredact = ["faces", "personal_text"]Covers each listed class on the device before the decision; a listed class with no redactor refuses the release
On deviceon_device = trueRefuses every release at the destination step
Public networks onlyprivate_networks = false, or the gate built with EgressPolicy::public_only() or an allowlistRefuses a host on a loopback, private or link-local address at the destination step; the gate's policy is the ceiling the switch narrows. Cloud metadata endpoints are refused either way
Stream privacywith_privacy(hook) on StreamPipeline::builder, SourceSpec or LiveCameraRedacts every frame before any other stage sees it
Cover people on the live cameraLiveCamera::cover_peopleCovers every detected person before a frame is shown or kept
Distrust the workspace fileVisionPack::distrust_workspace_rulesA workspace .adk/vision.toml's allow rules and default ask, and with no file every release asks
Harness modeReadOnly or PlanDenies every vision call that sends an image off the machine, whatever the rules allow
# .adk/vision.toml: crops to Anthropic go after faces and personal text are covered; whole
# pages ask; nothing goes to OpenRouter.
[egress]
default = "ask"
redact = ["faces", "personal_text"]

[[egress.rule]]
provider = "anthropic"
classes = ["document_crop"]
action = "allow"

[[egress.rule]]
provider = "openrouter"
action = "deny"

A rule names exactly one of host and provider; rules match in order, the first match decides, and a backend with several hosts gets the strictest of their decisions. A provider is the id a model's responses carry in LlmResponse::provider, which adk_core::Llm::data_destinations names with the hosts of the client's configured endpoint: a custom base URL, a Vertex AI location or a Bedrock region is the host a rule sees.

What Is Redacted

When the rules list a class, the gate fills each region solid black — blur and pixelation of text can be reversed — then encodes the copy that leaves. Redactors run on the device and answer in the pixels of the image about to be released:

ClassRedactorFinds
facesFaceRedactor over an on-device face Detector, with a person Detector as its fallbackEach detected face, widened by FACE_MARGIN (15% of its longer side), and the whole box of each detected person with no face inside (spec 3.7 Q3)
facesPersonRedactor over any on-device DetectorThe whole box of every detected person, for a deployment with no face detector
personal_textPersonalTextRedactor over any on-device DocumentReaderWords adk_guardrail::PiiRedactor's patterns match — email, phone, SSN, card number — and the values of labelled fields such as Name:
markedThe caller's regionsRegions a call names for redaction

PiiRedactor::find reports each match as a byte range of the text it searched; PersonalTextRedactor joins each block's words with single spaces, so every range maps to the words it covers and their boxes. A labelled field's value is covered whether the reader returns it on the label's line or as the next block to its right. A class the rules list with no redactor installed refuses every release, and a redactor refuses a remote backend.

A face counts as a person's when its centre lies inside the person's box, so a person seen from behind, or a face turned away or too small for the face detector, is still covered — as the whole person. A person whose face is found keeps the rest of the picture: a close desk frame is no longer blanked by one person's box. An approval card draws a face as faces and a person covered whole as people, and its caption says which:

CoveredCaption
One face1 face covered
One person, no face found1 face · the whole person is covered
Both2 faces covered, 1 as the whole person

The receipt and the vision.egress.released record count both under faces, the class the rules list.

The Default Redactors

Each redactor takes any on-device backend, or builds the default one from adk-vision's built-in manifest:

ConstructorFeatureBackendWeights
FaceRedactor::on_device(fetcher)onnxYuNet faces at a score of 0.5 or more; RF-DETR Nano for each person at 0.25 or more with no face foundyunet-2023mar, 232 KB, MIT; rf-detr-n, 108 MB, Apache-2.0
PersonRedactor::rf_detr(fetcher)onnxRF-DETR Nano, COCO person at a score of 0.25 or morerf-detr-n, 108 MB, Apache-2.0
PersonalTextRedactor::pp_ocr(fetcher, size)guardrail, ocrPP-OCRv6 tiny, small or mediumpp-ocrv6-{size}-det and -rec; small is 31 MB, Apache-2.0

The default backend loads on the redactor's first use, through the ModelFetcher, with every file checked against its SHA-256 before it loads. A load that fails — HF_HUB_OFFLINE with the weights not cached, a digest mismatch, no network — fails that call, so the gate refuses the release at its redact step and records why; the next call tries the load again. One load errs toward covering instead: a FaceRedactor whose face detector cannot load covers every person its fallback finds as the whole person, with a warning. The harness vision pack installs these defaults (feature vision-local) for faces and personal_text when the rules list them and no redactor of the operator's covers them; PERSONAL_FIELD_LABELS lists the field labels it covers.

Note: RF-DETR is trained on photographs: the drawn portrait of the test identity card scores 0.11 as a person. YuNet finds the drawn faces of the scenario fixtures (scores 0.64 to 0.91 from 60 px to most of a 1280×720 frame), so FaceRedactor covers them too.

The Face Detector

Spec 3.7 Q3 asked for a permissively licensed face detector with an ONNX export. The candidates, with the licence of their weights:

DetectorCodeWeightsONNXDecision
YuNet 2023mar (OpenCV Zoo, opencv/face_detection_yunet)MITMIT ("all files in this directory", the model included)Official, 232 KB, opset 11Chosen: yunet-2023mar in the built-in manifest
SCRFD, RetinaFace (InsightFace)MITNon-commercial research only (InsightFace README)OfficialExcluded
YOLOv5-face, YOLOv8-faceGPL-3.0, AGPL-3.0Same as the codeCommunityExcluded (copyleft)
BlazeFace (MediaPipe)Apache-2.0Apache-2.0 (Google model card)Community conversions only, 128×128, about 2 m rangeNot chosen: no first-party ONNX, short range
UltraFace (Linzaer)MITMITONNX Model Zoo, 320×240Not chosen: lower accuracy than YuNet

YuNet and most face detectors are trained on WIDER FACE, whose images are distributed for research; the published YuNet weights carry the MIT licence regardless, as OpenCV itself ships them. A deployment that needs a detector trained on other data registers its own manifest and passes the detector to FaceRedactor::new.

Face detection redacts and nothing else (V-I8): YuNet detects faces, it never recognises or compares them, and no manifest holds a recognition model.

The adk-harness test s3_the_default_redactors_leave_no_face_and_no_personal_string checks the harness vision pack's default redactors on the identity-card fixture and two COCO photographs, under rules that list both classes: YuNet finds no face, and PP-OCRv6 tiny, small and medium none of the seeded personal strings, in the bytes the provider received.

Faces on Streams

A stream's frames are not redacted unless a privacy hook is given: with_privacy(hook) on StreamPipeline::builder, SourceSpec or LiveCamera, and keyframe_privacy(hook) on the video analyst. A hook runs before any other stage, so a stored frame was redacted before its write (V-I9). RedactorPrivacy::blur_faces(fetcher) (feature onnx) is the face blur of spec 3.7 S18: FaceRedactor::on_device under RedactionMethod::FACE_BLUR, a Gaussian whose standard deviation is a quarter of each box's longer side, so a near face is blurred as hard as a far one, with each face held for two frames so a frame in which YuNet misses a moving face still blurs it. See Streams.

The On-Device Profile

on_device = true in the [egress] table of .adk/vision.toml keeps every image on the machine: the gate refuses every release at its destination step, before anything is cropped or redacted, whatever the rules say, and records the refusal with its reason. An escalation it refuses leaves the on-device answer standing. The harness vision pack's default fetcher then works offline, as under HF_HUB_OFFLINE=1, and so does adk-rust vision run.

# .adk/vision.toml
[egress]
on_device = true

Run the agent with HF_HUB_OFFLINE=1 and a warm cache, and inside a sandbox with the network denied — Seatbelt on macOS, bubblewrap on Linux (Code Execution Sandbox):

LayerWhat it refusesWhere it is recorded
The egress gateEvery image release, at the destination stepvision.egress.refused, the EgressRecorder
The model fetcherEvery download: a cached file is verified and returned, a missing one is an errorThe error
The sandboxEvery socket the process opensAn adk-sandbox egress proxy that admits no host records each attempt

Scenario S19 of examples/vision runs S1 this way and checks that the forty pages are read on the device, that each of the five escalations is refused at the gate with its reason, and that the sandbox's egress record is empty. On Windows the sandbox does not enforce a denied network, so only the gate and the fetcher hold there.

The Guardrail

PathHookBehaviour
Model callsImagePrivacyGuardrail::before_model_callback, on an agent whose model is remoteEach image part in the request — user uploads and the inline images of function responses — is released as data class model_context, or replaced by a text placeholder naming its digest and why it was withheld
Tool resultsToolGuardrail::validate_resultA base64 image in a result's JSON — a data:image/...;base64, URL or bare PNG, JPEG, WebP or GIF base64 — is replaced by its released copy or a placeholder
User inputGuardrail::validateAs for model calls, returned as Transform
use std::sync::Arc;

use adk_agent::LlmAgentBuilder;
use adk_vision::{EgressGate, ImagePrivacyGuardrail};

fn guarded(
    model: Arc<dyn adk_core::Llm>,
    gate: Arc<EgressGate>,
) -> adk_core::Result<adk_agent::LlmAgent> {
    // No hosts given: the guardrail releases to the hosts the model names.
    let guardrail =
        Arc::new(ImagePrivacyGuardrail::for_model(gate, model.as_ref(), Vec::<String>::new()));
    LlmAgentBuilder::new("desk")
        .model(model)
        .before_model_callback(guardrail.before_model_callback())
        .build()
}
  • Locality. ImagePrivacyGuardrail::for_model reads Llm::data_locality(). A model in this process or on loopback is not guarded, since nothing leaves.
  • Destinations. Images are released to the hosts given, or with none to the hosts and providers of Llm::data_destinations().
  • Released parts. A part the gate released carries a release annotation; it passes again only when its bytes hash to a digest that gate released, so a forged annotation is gated.
  • Rules. Under the default allow, an image bound for a model's context is released as it is. A rule that asks or denies for the model's host or provider and class model_context withholds it with a placeholder; the vision tools can still read it on the device.
  • Boundary. User code that calls an Llm directly, without the guardrail, is outside this guarantee.

Safeguards That Always Apply

These hold whatever the rules say; the configurable ones are set where the table names.

SafeguardDefaultConfigure with
Decode caps on every image50 MB and 50 megapixelsDecodeLimits::with_max_bytes, DecodeLimits::with_max_pixels
Per-backend input limitsEach adapter's documented limit; larger images downscaled, with the resize on the transform chainLlmDescriber::with_limits, BackendDescriptor::with_limits
Model digest and size checksEvery file checked against its manifest's SHA-256 and size before it loadsA user manifest in a ManifestSet names its own files
Licence acceptance for use-restricted weightsNothing loads until a person records acceptanceadk-rust vision models accept, or an AcceptanceStore
Text read from an image is untrustedScreened and delivered inside a delimited block in the harness—
Screen-plan limitsA plan holds at most 10 actionsComputerUsePack::with_plan_max_actions, ScreenPlan::with_max_actions
Unknown keys in .adk/vision.tomlRefused, not ignored—
Every release recordedBefore the request is sentAn EgressRecorder, the run's audit trail

Invariants

InvariantEnforced by
V-I1A remote backend receives only a ReleasedImage, and only the egress gate constructs oneThe type system: remote backends implement their trait for ReleasedImage
V-I2Redaction of every listed class precedes the decision and the release; no configuration releases before itThe gate's step order; .adk/vision.toml refuses unknown keys
V-I3Every release writes its record, with source and egress digests and the destination, before the request is sentEgressRecorder and the run's audit trail (vision.egress.released)
V-I4With the vision pack, the guardrail is on for remote model calls, and no agent tool removes itadk-harness feature vision
V-I5A held vision call carries its evidence, and a different image holds it againThe egress digest in the call's fingerprint
V-I6A priced call opens its hold before its requestThe runtime's preflight, before any image is released
V-I8Face and person detection only redact; no manifest holds a recognition modelFaceRedactor, PersonRedactor; the built-in manifest
V-I9A stored frame passed its source's privacy hook, when one is set, before the writeFramePrivacy makes the only frame a FrameKeeper stores
V-I15Records carry digests and artifact references, never pixelsvision.* records
V-I17A freeze refuses every vision call and every releaseVisionCx::check at each step
Restricting What Leaves the Machine - ADK-Rust दस्तावेज़ीकरण | ADK-Rust