AutoDroid-V2: Boosting SLM-based GUI Agents via Code Generation

Hao Wen, Shizuo Tian, Borislav Pavlov, Wenjie Du, Yixuan Li, Ge Chang, Shanhui Zhao, Jiacheng Liu, Yunxin Liu, Ya-Qin Zhang, Yuanchun Li

Abstract

Mobile GUI agents traditionally rely on iterative, step-wise interactions that suffer from high latency and privacy concerns. AutoDroid-V2 redefines this process by reframing UI automation as a code generation task. By utilizing Small Language Models (SLMs) to generate multi-step scripts based on automated app documentation, the system achieves a 54.4% success rate on complex tasks while reducing latency by over 13x compared to traditional cloud-based agents.

Introduction: The Limitations of Step-Wise Agents

Most contemporary mobile GUI agents operate through a "step-wise" loop: capturing a screenshot, querying a model for a single action, executing it, and repeating. While effective with large-scale models like GPT-4o, this approach faces significant hurdles for on-device deployment. High latency from repeated cloud queries, privacy risks associated with transmitting UI states, and the "SLM Gap"—where smaller models struggle with reasoning but excel at coding—necessitate a more efficient paradigm.

Comparison of step-wise vs. script-based UI automation approaches.

The AutoDroid-V2 Framework

AutoDroid-V2 addresses these challenges through a two-stage framework that shifts the burden of reasoning from real-time interaction to pre-computed documentation and single-shot code generation.

The AutoDroid-V2 architecture, illustrating the offline documentation/synthesis stage and the online execution stage.

1. Offline Stage: Automated Documentation and Data Synthesis

To enable an SLM to interact with an app without constant visual feedback, AutoDroid-V2 constructs a compressed App Document. This document identifies abstract GUI states and groups redundant elements (e.g., list items) into functional types. To overcome the scarcity of UI-to-code datasets, the system employs an "inverse" synthesis approach: it generates synthetic tasks from sampled UI elements and uses a "Solution Verifier" (leveraging Depth-First Search and reward models) to find valid code solutions. This synthetic data is then used to fine-tune a local SLM, such as Llama-3.1 8B.

2. Online Stage: Script-Based Execution

Upon receiving a user command, the local SLM generates a complete Python-like script using a domain-specific library. This script can include loops and conditional logic, allowing for complex multi-step operations in a single inference pass. A custom interpreter executes the script, utilizing "backward dependencies" to navigate the app if the expected UI state is lost. Furthermore, the system employs prompt caching for the static App Document, ensuring that runtime inference is nearly instantaneous.

Evaluation and Results

The framework was evaluated on the DroidTask benchmark (158 tasks across 13 apps) and a subset of Android in the Wild (AitW).

  • Accuracy: AutoDroid-V2 achieved a 54.4% success rate on DroidTask, significantly outperforming the 43.9% achieved by the best step-wise baseline.
  • Efficiency: When deployed on a Snapdragon 8 Gen 2 processor (OnePlus ACE 2 Pro), the system reduced average task latency from 669.2 seconds to just 46.3 seconds—a 13.4x improvement.
  • Resource Consumption: The script-based approach reduced input token usage by 43.5x and output tokens by 5.8x, making it highly suitable for resource-constrained mobile hardware.

Discussion and Future Directions

The success of AutoDroid-V2 highlights code as a reasoning shortcut for SLMs. By treating an app as a finite state machine with a defined API, the agent bypasses the need for continuous visual processing. However, limitations remain. The system's reliance on structured text (XPaths) makes it less effective for non-standard UIs like games. Future work may explore hybrid models that combine the efficiency of script-based planning with the flexibility of step-wise reflection for hyper-dynamic environments.

Conclusion

AutoDroid-V2 demonstrates that high-performance mobile GUI automation is possible on-device. By leveraging the coding strengths of SLMs and automated app mapping, it provides a fast, private, and accurate alternative to cloud-dependent agents.

Summary updated

BibTeX
@inproceedings{wen2024autodroid,
  author = {Hao Wen and Shizuo Tian and Borislav Pavlov and Wenjie Du and Yixuan Li and Ge Chang and Shanhui Zhao and Jiacheng Liu and Yunxin Liu and Ya-Qin Zhang and Yuanchun Li},
  title = {{AutoDroid-V2: Boosting SLM-based GUI Agents via Code Generation}},
  booktitle = {MobiSys},
  year = {2024},
  url = {https://openreview.net/forum?id=nFijZMiXQs},
}
Figure