adk-vision
Local-first perception for Rust Agent Development Kit (ADK-Rust) agents.
Stability: Experimental — new in 3.0.0 (spec 3.7), and its API may change while the spec lands. See STABILITY.md.
Note: this release holds the contracts — media, regions, manifests, traits, the runtime, the egress boundary and the conformance suite, the local ONNX backends (
onnx), the document readers (ocr,ocr-vl,nim), and the cloud backends: Gemini, Claude, Muse and NVIDIA NIM describers (cloud,nim) and Metasam-3.1(sam). mistral.rs backends arrive as a feature in a later release.
Overview
adk-vision gives an agent sight through contracts first:
| Contract | Type | What it guarantees |
|---|---|---|
| Media | ImageRef, Frame, VideoRef, MediaStore |
Pixels enter once and are stored as artifacts by sha256: digest; the digest is what travels |
| Regions | Region, RegionSet, CoordFrame, TransformChain |
Every region is in source-image pixels and records the frame its backend answered in and the transforms in between |
| Manifests | ModelManifest, LicenceGate, VerifiedModel |
Every weight file is pinned by revision and SHA-256 and names its licence; nothing loads unverified |
| Traits | Detector, Segmenter, DocumentReader, Embedder, Describer, Tracker, VideoAnalyzer, Editor |
One contract per perception task, each with a conformance suite |
| Runtime | VisionRuntime |
Local-first routing, metering, cancellation, mapping to source pixels, crop escalation |
| Egress | EgressGate, ReleasedImage, ReleasedClip |
A remote backend only ever receives an image the gate cropped and recorded — redacted and approved when the rules opt in — or a clip it checked and recorded |
| Video | SourceClip, VideoSource, FramesAnalyzer, VisibilityPass, SamVideoTracker |
analyze_video holds a call's frames before anything leaves; questions and chunk captions over sampled frames on any model (cloud), questions optionally only around the first frame that shows the question's subject; tracks through a clip with sam-3.1 video (sam) |
| Tools | VisionToolset |
vision_detect, vision_segment, vision_read, vision_describe, vision_crop, vision_redact, vision_annotate, vision_measure, vision_video (frames in time order asked about, captioned or tracked), and vision_watch over registered frame sources (stream), on the governed path; under a rule that asks, a remote call is held with the exact egress image and releases only that digest |
| Watch | WatchCondition, WatchEvaluator, WatchSink |
Conditions held on the device against tracked objects; one event per object, keyed for the kernel's VisionWakeSource, never carrying pixels |
| Memory | VisualMemory, VisualQuery, SiglipTextEmbedding |
Image embeddings as adk-rag chunks in any vector store, found by text or an example image; one embedding space per collection; captions with artifact references in adk-memory; erasure by source (memory) |
| Video analyst | VideoAnalyst, Chunking, WordHashEmbedding |
A video cut into fixed or scene chunks, each captioned through the video analyzer and indexed in any vector store with its time range; captions in adk-memory, the clip in graph memory, keyframes in visual memory; questions answered citing chunks; cost per hour of video; erasure by clip (analyst) |
| Measurement | Calibration, Measurement |
A fiducial of known size gives pixels per millimetre; maximum length and area from masks with their uncertainty, valid only in the fiducial's plane |
| Privacy, opt-in | FaceRedactor, PersonRedactor, PersonalTextRedactor, ImagePrivacyGuardrail, RedactorPrivacy::blur_faces |
When the rules list them, faces and personal text filled solid black on the device before an image leaves — YuNet faces with RF-DETR Nano for people with no face found (onnx) and PP-OCRv6 (ocr), loaded on first use; the same gate on model requests, tool results and user input; faces blurred on a stream given the hook; the on-device profile (on_device = true) that releases nothing |
[]
= { = "3.0.0", = ["fetch"] }
Through the umbrella crate, adk-rust feature vision (in full) brings the pure-Rust
features — fetch, cloud, nim, sam, guardrail — as adk_rust::vision, and
vision-local (in no tier) adds the on-device backends: onnx, ocr and ocr-vl.
| Feature | Contents |
|---|---|
| (always) | media, geometry, manifests, the traits, VisionRuntime, the egress gate, the deterministic Editor, VisionToolset, FaceRedactor, PersonRedactor, the vision.* audit records, watch conditions, calibration and measurement, the verifier loop (VerifierLoop) |
fetch |
ModelFetcher: Hugging Face downloads by revision through hf-hub 0.5, SHA-256 checked before load, HF_HUB_OFFLINE honoured |
conformance |
The conformance suite and its per-trait test macros |
eval |
VisionEvalAgent: any runtime task answering adk-eval cases in the vision tools' response form, in process or over the cargo adk eval protocol (serve_eval_protocol) |
guardrail |
ImagePrivacyGuardrail (a BeforeModelCallback, an adk-guardrail Guardrail and ToolGuardrail) and PersonalTextRedactor over PiiRedactor's byte ranges |
onnx |
Local backends on ONNX Runtime: RfDetr, EfficientSam, Sam2, SigLip2, YuNet; onnxruntime downloaded at build time |
onnx-dynamic |
The same backends against an onnxruntime library loaded from ORT_DYLIB_PATH |
onnx-coreml, onnx-cuda |
The CoreML and CUDA execution providers for the onnx backends |
sam3-local |
Sam3 (concept segmentation and detection) and Sam3Tracker (points and boxes): Meta's SAM 3 on ONNX Runtime from weights you supply with your own manifest under the SAM License, loaded only after a person accepts it; no weights or built-in record ship; in no adk-rust tier; implies onnx |
cloud |
LlmDescriber: any adk_core::Llm that takes images as a Describer, with Gemini (box_2d, 0–1000), Claude (pixels of the image as sent) and prompt-fixed 0–1000 region adapters, and provider-formula preflight estimates; LlmDescriber::local over a model on this machine, such as adk-model's OllamaModel with a vision model |
nim |
NVIDIA NIM: vision-language models (NimConfig, reasoning off, unpriced) and NimDocumentReader for NVIDIA's OCR, page-element, table and chart endpoints, remote, behind the egress gate; implies cloud |
sam |
SamSegmenter: Meta sam-3.1 request building, stream parser and mask placement, billed per request at $2.50 per 1,000 images; masks as boxes, or decoded by a program you installed (ExternalMaskDecoder) |
sam-codec |
LicensedMaskDecoder: sam-3.1 masks decoded in process by adk-vision-sam-codec, the port of Meta's codec under the SAM License, once a person accepts it (adk-rust vision models accept sam-mask-codec); in no adk-rust tier; implies sam |
ocr |
PpOcrReader: PP-OCRv6 text lines and words through oar-ocr on ONNX Runtime |
ocr-vl |
PaddleOcrVlReader: PaddleOCR-VL-1.6 with PP-DocLayoutV3 through oar-ocr-vl on Candle |
ocr-vl-metal |
ocr-vl on Apple GPUs through Candle's Metal backend |
mistralrs |
LlmDescriber::mistralrs: Qwen3-VL (qwen3-vl-2b-instruct, qwen3-vl-4b-instruct and qwen3-vl-8b-instruct, built in) or another mistral.rs vision model in this process, verified before load, regions in Qwen3-VL's own 0–1000 frame; implies cloud, fetch |
mistralrs-metal, mistralrs-cuda |
mistralrs on Apple GPUs or CUDA |
stream |
FrameSource, Sampler, the FrameGovernor, FrameKeeper retention and StreamPipeline (source, sampler, governor, privacy hook, detector metered in frames, tracker, observation sink); StreamWatch, the watch stage that keeps each event's frame and wakes a WatchSink; FrameSources, the operator's named sources, and vision_watch over them |
rtsp |
RtspSource: RTSP cameras through retina; MJPEG decoded in process, H.264 and H.265 with ffmpeg |
ffmpeg |
FileSource (MP4, MOV) and H.264/H.265 decoding through a user-installed ffmpeg; nothing vendored or downloaded |
device |
DeviceSource: a camera on this machine (AVFoundation on macOS, v4l2 on Linux, DirectShow on Windows) through the same user-installed ffmpeg, DeviceSource::list and a testsrc2 stand-in; implies ffmpeg |
screen, browser, surface-camera |
ScreenSource (a ComputerActuator or computer-use-mcp observations), BrowserSource (browser_screenshot), SurfaceCameraSource (frames the web home pushes) |
stream-fixtures |
The generated conveyor clip and an in-process RTSP test server |
track |
ByteTracker: ByteTrack through trackforge 0.5, anonymous tracks that keep their identifiers through jitter and occlusion |
computer-use |
GroundedTarget::target_evidence: a chosen set-of-marks candidate as adk-computer-use TargetEvidence, bounds in logical points at the screenshot's device pixel ratio; with screen, stream::RuntimeObserver and stream::screen_source: any ComputerUseRuntime as a screen frame source |
gemini-video |
GeminiVideoAnalyzer: Gemini native video, uploading clips above 20 MB once through the File API, at an explicit frame rate and media resolution; implies cloud |
memory |
VisualMemory: image embeddings as adk-rag chunks with the caption, artifact, digest, region, source, capture time and run; text and example-image search with day, kind and source filters; the collection's embedding space recorded and any other refused; captions in adk-memory and sources in its graph memory; erase_source with a vision.memory.erased record; the S16 week corpus |
memory-lancedb |
The visual memory tests against adk-rag's embedded LanceDB backend (needs protoc) |
analyst |
VideoAnalyst: fixed-window or scene-cut chunks captioned by VideoRequest::Caption through the runtime, indexed as adk-rag chunks with their time range, keyframe and clip; captions with artifact references in adk-memory, the clip and what it shows in graph memory, keyframes into a VisualMemory, through keyframe_privacy when set; ask from retrieved captions with chunk citations; cost per hour of video; erase_source with a vision.analyst.erased record; WordHashEmbedding; the S17 warehouse clip (implies cloud, memory, stream) |
team |
team: the Perceiver, Reasoner and Verifier roles, each refusing at construction what it may not hold, and VisionTeam, which escalates a reasoner/verifier disagreement to a person on one card with both opinions and the frame; implies guardrail |
Quick Start
A backend answers in its own frame; the runtime prepares the image it sees and maps the answer back to source pixels:
use Arc;
use ;
/// Finds the whole image, in the pixels it was sent.
;
async
Local Backends
Feature onnx runs RF-DETR detection (and RF-DETR-Seg instance masks), EfficientSAM-Ti
and SAM 2.1 Tiny point and box segmentation, SigLIP 2 image and text embeddings, and YuNet
face detection for the privacy redactors on the device. Each backend loads a VerifiedModel
from the built-in manifest (eleven Apache-2.0 records and MIT-licensed YuNet, pinned by
commit and SHA-256) or your own, such as an RF-DETR fine-tune:
use Arc;
use ;
use ;
async
See Local ONNX backends for the models, prompts, execution providers and measured latency.
Coordinate Frames
Providers answer in different frames. Each backend's descriptor names its CoordFrame, and
the runtime records every Transform between the source image and what the backend saw:
| Frame | Who answers in it | Mapped to source by |
|---|---|---|
SentPixels |
Meta sam-3.1; Claude once the runtime resized to its limit; local backends that undo their own letterbox |
the transform chain |
Normalized { scale: 1000, order: Yx } |
Gemini's box_2d ([ymin, xmin, ymax, xmax]) |
scale to the sent size, then the chain |
ModelInput { width, height, letterbox } |
RF-DETR and SAM 2 tensors | undo the letterbox, then the chain |
ScreenSpace turns screenshot pixels into logical points for a click: a 3024×1964
screenshot of a display at device pixel ratio 2 is 1512×982 points. RegionSet is the wire
form, published as a JSON Schema in schema/region-set.json.
adk_vision::screen grounds actions on a screenshot by set-of-marks: MarkSet numbers the
candidates from browser_elements, local OCR words or a model's point, vision_annotate
draws them at the device pixel ratio, and the chosen mark's GroundedTarget is a
browser_click selector or a click point in logical points with the screenshot's digest.
FittedActuator resizes screenshots to Claude's image limits for computer_toolset_20260801
and scales clicks and zoom regions back; ScreenPlan is one approval for a previewed plan of
up to N actions in one window, each action checked against its preview before it runs. See
Screen Grounding.
Remote Backends and the Egress Gate
An on-device backend implements its trait for SentImage; a remote backend implements it
for ReleasedImage, so handing a remote backend an unreleased image does not compile. Only
EgressGate::release constructs a ReleasedImage, after six steps:
- Destination — the on-device profile refuses every host; otherwise the adk-core
EgressPolicydecides each host. - Minimise — crop to the region the call needs, downscale to the backend's limit.
- Redact — every class the rules'
redactlist names (faces,personal_text, ...) is filled with solid colour by itsRedactor; a listed class with no redactor, or a redactor whose default weights cannot load (FaceRedactor::on_device's person fallback,PersonRedactor::rf_detr,PersonalTextRedactor::pp_ocr), refuses the release. The list is empty by default. - Decide — the rule for the host or provider and the data class says
deny,askorallow, the default;askholds until a person approves that exact egress digest. - Record — the receipt (source and egress digests, chain, redactions, decision) goes to
the
EgressRecorderbefore the image is returned. - Release.
The rules live in .adk/vision.toml. With no file, every image leaves as it is and is
still recorded; each restriction is an opt-in, enforced once chosen, and a listed redaction
class always runs before the decision:
[]
= "ask"
= ["faces", "personal_text"]
[[]]
= "generativelanguage.googleapis.com"
= ["document_crop"]
= "allow"
[[]]
= "openrouter"
= "deny"
A rule names a host or a provider. LlmDescriber::remote takes both from the model
(adk_core::Llm::data_destinations), so a custom base URL, a Vertex AI location or a
Bedrock region is the host the rules see; remote_with_hosts names them by hand. See
Restricting What Leaves the Machine.
Routing and Escalation
A route names a primary backend and an optional escalation. On a low score, no result, or
disagreement with a second on-device backend, the runtime crops the uncertain region plus a
margin and sends only that crop — never a whole image when a region will do. The escalated
answer replaces the primary's and records escalatedFrom:
use ;
let runtime = builder
.detector
.remote_detector
.egress_gate
.route
.build?;
Every call is metered against the context's ModelCallScope: images are recorded as
units, at the unit price for a per-unit backend and at zero cost for a local one. A frozen
kill switch refuses every call and every release.
Document Readers
PpOcrReader (ocr), PaddleOcrVlReader (ocr-vl) and NimDocumentReader (nim) answer
VisionRuntime::read in one DocumentPage, published as a JSON Schema in
schema/document-page.json: blocks with regions in source
pixels, text, confidence, words and table cells, the reading order, and Markdown. The local
readers load models from the built-in manifest (pp-ocrv6-{tiny,small,medium}-{det,rec},
paddleocr-vl-1.6, pp-doclayoutv3, all Apache-2.0); the NIM reader takes only released
images. See Document readers.
Model Manifests and Licences
A ModelManifest pins each file by Hugging Face commit and SHA-256 and names its licence:
| Licence class | Fetched and loaded when |
|---|---|
permissive |
always |
useRestricted |
a person's acceptance is recorded (adk-rust vision models accept <id>); no agent tool records one |
nonCommercial, copyleft |
the user's LicencePolicy names the model; never in the built-in manifest |
ModelFetcher (feature fetch) reads HF_HUB_CACHE, HF_HOME, HF_TOKEN, HF_ENDPOINT
and HF_HUB_OFFLINE by Python's conventions. With HF_HUB_OFFLINE=1 it opens no socket. It
checks every file's size and SHA-256 after download and before every load, and refuses a
mismatch with both digests. A 401 or 403 is a gated repository and asks for licence
acceptance. Backends take a VerifiedModel, which only verification constructs.
Conformance
Every backend runs the same suite through a VisionRuntime: coordinates in source pixels,
usage recorded, cancellation, the kill switch, no egress from local backends, oversized
input, and rate-limit mapping; a video analyzer runs video_analyzer_conformance_tests!
(frame metering, egress, event times, refusals). Enable conformance in
[dev-dependencies]:
Streams
StreamPipeline reads a camera, a file, a screen, a browser page or the web home's camera,
holds it to a FrameBudget (lower the rate, stop escalating, pause, resume next period),
redacts every frame, when given a PrivacyHook with with_privacy —
RedactorPrivacy::blur_faces blurs faces — before any other stage, detects and
tracks on the device, and hands each frame to an ObservationSink. Frames stay in memory
unless a wake, a card or a person keeps them through FrameKeeper, which stores only
frames that passed the privacy step, for 30 days by default. StreamWatch holds watch conditions against the
stream, keeps the frame of each event that passes and wakes a sleeping agent through the
kernel's VisionWakeSource; FrameSources and the vision_watch tool let an agent start and
stop those watches on the sources an operator registered. See
Streams and
Watch conditions and visual wakes.
Visual Memory
VisualMemory (feature memory) embeds each image through the runtime and stores it as an
adk-rag chunk in any VectorStore: the caption is its text, the artifact its source_uri,
and its metadata names the digest, region, source, capture time and the run that stored it.
search_text and search_image find images in the same SigLIP 2 space, and every hit links
to its artifact and run. The collection records its embedding space and refuses any other, so
a new embedder means a new collection. Captions go to adk-memory with a reference to their
artifact, and erase_source removes a source's chunks, captions, graph entity and unshared
artifacts. See Visual memory.
VideoAnalyst (feature analyst) cuts a video into fixed windows or scene cuts, captions
each chunk through the runtime's video analyzer — on the device, or remotely with every frame
through the egress gate — and indexes the caption in any adk-rag vector store with the
chunk's time range, in adk-memory with references to its keyframe and clip, and in graph
memory under the clip. ask answers from the captions a retrieval finds and cites the chunks
it rests on; IndexedClip::cost_per_hour_micro_usd is the captioning's cost per hour of
video. See The video analyst.
Documentation
- Getting started: a Document desk, from
cargo adk new <name> --template vision - The
adk-rust visionCLI: manifests, licences, one call through the egress gate, the egress log - Scenarios S1–S19 (
examples/vision): the Document desk on local backends and recorded cloud responses; phase B's Inspector, wakes, frame budgets, live camera surface and native video; phase C's Screen copilot, team, visual memory and video analyst; face blur on streams and the on-device profile - Vision overview
- Governed vision tools
- Restricting what leaves the machine
- Cloud vision backends
- Vision evals
- Vision benchmarks
- Streams: sources, sampling, the frame governor, the privacy step, retention and the stream pipeline
- Video and tracking: the video analyst — chunks captioned, indexed and answered with citations, cost per hour of video
- Visual memory: image embeddings as
adk-ragchunks, text and example-image queries, one embedding space per collection, captions inadk-memory, erasure by source - Spec 3.7
License
Apache-2.0