How I got a phone screen down to 59 tokens and 13ms for AI agents (without screenshots or an installed app)
Scroll a long list on Android and something sneaky happens behind the glass. The view holding "Row 13" does not scroll off the top and vanish. Android peels off its label and hands the exact same node ID to "Row 29" down at the bottom. An AI agent tracking that ID will happily tap sixteen rows off, and Android will return a polite ok . Most mobile-agent headaches look like that. Reading an…
Phonedriver is a tool designed to streamline interactions with mobile devices, reducing the amount of data sent between the AI agent and the device. It achieves this by minimizing the XML output from adb shell uiautomator dump from 25KB to just 461 bytes. This is accomplished through several systems tricks, such as dropping invisible and off-screen nodes, hoisting child TextView labels onto clickable wrapper layouts, collapsing single-child decorative containers, and rendering the on-screen keyboard as a single keyboard line.
To avoid the recycled-row bug, phonedriver only follows a platform node ID when the role matches and either the label is untouched or the bounds have drifted less than 8 points. This ensures that the element references stay accurate even during scrolls. Every tap triggers a fresh tree resolution, allowing the model to only receive what has changed, rather than re-reading the entire phone on every turn.
Phonedriver can be used with MCP (Claude Code, Codex, Cursor, VS Code, Gemini CLI) or as a plain CLI. It supports both Android and iOS, with a Rust implementation that is open-source under AGPL-3.0 with zero telemetry. The tool was developed to address the challenges of mobile-agent headaches, such as reading an accessibility tree fast, keeping element references honest across scrolls, and determining when a screen has stopped moving without relying on hardcoded sleeps.
The tool's performance is quite impressive. For example, on an API 37 emulator, the plain adb screen read took 12.7ms, while phonedriver achieved a screen read time of just 12.7ms. On a real HONOR X8 (Android 13), phonedriver's screen read time was 78.5ms compared to 2,507ms for adb's uiautomator dump. Additionally, phonedriver's type-and-check operation took 158ms, whereas adb's took 3,638ms.
The tool also handles real Android bugs like stale caches and unbinding TalkBack, ensuring a smooth and efficient experience for developers.
Rewritten by urgent.news; may contain errors — check the original.
Source: dev.to