← All Lab Dispatches
Bambiko Labs

Why We Built Eyes-Off Handoff in Rust

Moving mobile agent orchestration out of JVM polling loops into bambiko-core—cutting memory footprint by 39% and enforcing an architectural privacy perimeter.

RustArchitecturePrivacy

Early prototypes of mobile UI agents almost always share the same skeleton: a desktop Python script talking over ADB, or a pure-JVM service spinning up allocations every time an accessibility tree changes. It works on a desk for a five-minute video, and then it melts your battery, triggers garbage-collection pauses mid-gesture, and leaks far too much context to external loggers.

When we built Bambiko, we wanted an architecture that felt native on a Pixel in your pocket—and safe enough to trust with real apps.

The Problem With Pure-JVM & Tethered Loops

Running an autonomous multi-turn loop on Android means tracking UI element trees, evaluating hardcoded rules first, persisting checkpoints so tasks survive process restarts, and deciding in milliseconds whether an action should fire or yield back to the user.

In our early JVM baseline, every loop turn churned Dalvik heap objects and paid IPC marshaling overhead. Worse, when privacy filtering lived in scattered Kotlin helpers, auditing what could or could not cross the network required reading half the codebase.

Enter bambiko-core (Rust + UniFFI)

We moved the core ReAct harness, rule evaluation, and state persistence into a single Rust crate compiled for arm64-v8a via UniFFI (libbambiko_core.so, ~1.1 MB stripped including SQLite).

On physical Pixel hardware, switching to the native Rust core delivered:

  • 39.1% lower Total PSS on the Play Store companion build (163.5 MB → 99.6 MB).
  • 52.5% lower Dalvik heap pressure (9.8 MB → 4.6 MB), eliminating GC stutter during rapid screen updates.
  • 5 ms 3-turn ReAct execution including atomic SQLite checkpoints—down from ~45–90 ms in pure JVM or ~36 seconds in tethered desktop loops.
  • < 100 μs actuator dispatch across the UniFFI vtable.

The Eyes-Off Perimeter

Performance was only half the reason to move into Rust. The bigger win is choke-point isolation.

In Bambiko’s hybrid Cloud-Planner / On-Device-Executor split, the local executor owns the screen tree, local embeddings, and audio buffers. Before any planning request is constructed:

  1. Window & Field Gating: Protected surfaces, password fields, and flagged contexts halt extraction locally.
  2. Text-First Scrubbing: Only sanitized, minimal text structure is eligible for cloud planning—raw screenshots and microphone wake buffers never leave the device.
  3. Deterministic Handoff: When a flow hits a human-only boundary—payments, final sends, or unrecognized prompts—execution stops cleanly and hands control right back to you.

Because the boundary lives in one audited Rust module rather than ad-hoc UI callbacks, Eyes-Off is a property of the data path itself—not a promise taped onto a prompt.

Shared DNA With Our Robotics Bench

Interestingly, building a deterministic Rust loop with clean actuator traits turned out to be useful far beyond phones. The exact same pattern—local perception, fast safety gates, bounded action traits, and optional high-level planning—now powers our desktop SO-101 robotics experiments in the lab.

More notes on that bridge soon.