AI Agent Safety Boundaries for Controlling Real Mobile Devices
This article examines how to build safe boundaries when AI agents operate real mobile devices. It covers human-in-the-loop approval, sensitive app isolation, independent execution spaces, and full auditability, along with a layered reference architecture and key engineering practices for running agent-driven mobile automation in production.
1. Background: When Agents Move from Outside the Screen to Inside It
In technical demos over the past two years, having AI coding tools or general-purpose agents directly operate real mobile devices is no longer just a concept. The capabilities described in the source material can be abstracted into a single pipeline: a small desktop client (on the order of tens of megabytes) runs on a computer and connects to an AI coding tool through a standardized tool integration protocol; the device side covers a range of relatively recent mobile OS versions; the agent performs taps, text input, swipes, and other actions on the device, and sends the UI state after each step back to the desktop.
The value of this pipeline is direct: a large amount of repetitive work that “requires someone to tap a few times on a phone,” such as daily check-ins, information inspections, and bulk form filling, can be automated. But the risks are equally direct: a phone is a terminal that combines identity, payment, and communication, so once an agent has full input capability, the cost of accidental or unauthorized actions rises sharply. The engineering focus, therefore, should not be on “whether it can operate the device,” but on “how to operate within controllable boundaries.”
2. Four Core Capabilities
2.1 Human-in-the-Loop Approval: Keep the Decision on the Human Side
The most important point to extract from the source material is that approval logic is not placed inside the agent itself, but in a middle layer the agent cannot bypass. Architecturally, this is a classic separation between the policy enforcement point and the policy decision point: the agent is the policy requester, the gateway is the policy enforcement point, and the human is the final decision maker.
In practice, it is recommended to classify actions by risk level:
- High risk and irreversible: payments, transfers, identity changes — require human confirmation by default;
- Medium risk and reversible: sending messages, submitting orders, deleting data, installing apps — can be switched to require confirmation depending on the scenario;
- Low risk and high frequency: browsing, querying, copying — can run automatically but must be logged.
A sample policy can be written as declarative configuration for easier review and version management:
policies:- name: payment_guardmatch: { action: input, target_class: payment }decision: require_human_approvaltimeout_seconds: 120on_timeout: deny- name: message_sendmatch: { action: tap, target_hint: "Send" }decision: require_human_approval- name: daily_checkinmatch: { action: sequence, scenario: checkin }decision: auto_allowaudit: full
The key design principle is fail-closed: if approval times out, the channel is interrupted, or UI recognition confidence is insufficient, the action is not executed rather than allowed through.
2.2 Sensitive App Isolation: Default Invisibility Beats After-the-Fact Blocking
The second capability is to make apps such as finance, wallets, and password managers invisible to the agent by default, and to avoid exposing the contents of password fields and verification code fields to it. This is more reliable than “detect a sensitive action and then block it,” because it shifts the attack surface from “detection accuracy” to “visibility control,” which is a direct application of the principle of least privilege.
This can be implemented in three layers: an app allowlist defines the range that can be interacted with; control-level masking defines which UI elements are readable and writable; and input channel restrictions define which fields never accept automated writes. With all three combined, even if the UI text is crafted to be misleading, the agent cannot obtain usable information or write capability.
2.3 Independent Execution Space: Automation Does Not Take Over the User’s Foreground
On newer OS versions, the system’s independent display and task scheduling mechanisms can be used to run automation tasks on a logically isolated surface, while the user’s own screen keeps its original ownership and is unaffected even when the device is locked. The point of this design is concurrency and experience: the machine working and the person using the phone do not block each other, and automation actions are not mistaken for genuine user operations.
Note that this capability depends on specific OS versions and vendor implementation differences. Engineering must include capability detection and a fallback path: if detection fails, fall back to “execute only when the device is idle and unlocked,” and clearly inform the user that the task has been deferred.
2.4 Full-Process Auditability: Screenshots, Screen Recording, and Replayable Reports
Whether an automation system can be trusted depends on whether it can be reviewed after the fact. It is recommended to record structured logs for each step (timestamp, action type, target control, UI hash, decision result) and unstructured evidence (screenshots, screen recordings), and to support exporting a report that opens in a browser, forming a replayable timeline. Logs themselves must be redacted to avoid retaining private on-screen content verbatim over the long term; evidence files should have retention periods and access controls.
3. Reference Architecture Layers
- Access layer: a standard tool integration protocol is used between the desktop client and the AI coding tool to abstract away device differences;
- Execution layer: the on-device agent handles action dispatch, UI structure collection, and capability detection;
- Control layer: the policy gateway handles approval, isolation, and rate limiting, and is the only path allowed to grant passage;
- Audit layer: a logging service and object storage handle structured records and screenshots/recordings respectively, with monitoring and alerting to flag abnormal frequency;
- Model layer: it can connect to different types of large model services; the model only outputs intent and action sequences and does not directly hold passage authority.
A typical call chain is as follows: the model produces an action intent → the execution layer collects the UI structure and filters sensitive controls → the control layer matches policies → if approval is required, a human confirmation is pushed → after approval, the action is executed and written to the audit log → the result is sent back to the model to continue reasoning.
4. Engineering Considerations
- Least privilege: grant only the app and control scope the task actually needs, and avoid global write access.
- Idempotency and rollback: design a corresponding undo or compensation path for each action, especially for submission operations.
- Rate and quota: set thresholds on the number of actions per unit of time to prevent model loops from causing bulk accidental actions.
- Human-in-the-loop usability: approval should support batching, context previews, and timeout policies; otherwise the human becomes the bottleneck.
- Compliance and disclosure: for operations involving accounts, communication, and payments, clearly inform users and keep an entry point for them to revoke authorization.
- Version difference management: capability detection results should drive feature switches; do not assume all devices behave the same.
5. Conclusion
The real barrier to “agents operating real phones” is not the accuracy of recognition and tapping, but boundary design: who can grant passage, what must be invisible, where execution happens, and how to review it. Making these four things default behaviors rather than options is what qualifies automation to enter production. For developers, a practical starting point is low-risk, reversible inspection tasks, using real approval trigger data to calibrate policy granularity, and then gradually expanding the scope of automation.
