On-Device AI Agents and No-Code Device Control: A Practical Architecture
This article explains how on-device (mobile) AI agents turn natural-language instructions into verifiable, replayable device-operation sequences, and why that matters more than raw model intelligence. It covers capability boundaries (semantic understanding, cross-app orchestration, on-device localization), a five-layer system architecture (perception, understanding, planning, execution, governance), how to convert natural language into an operation sequence with plan-then-execute and per-step verification, device-cloud collaboration under memory/power/thermal constraints, and an engineering checklist for shipping safely. Readers will learn how to build a governable operation loop with clear layering, verifiable actions, circuit-breakers for sensitive paths, and an explicit device-cloud split, so that execution and governance assets remain reusable even as the underlying model evolves. A sample action protocol is included.
Why We Need On-Device Agents That Can “Act”
Most traditional voice assistants and chat-style apps stop at question answering, retrieval, and simple navigation. The capability that actually reduces manual work is decomposing a single natural-language instruction—for example, “compress the photo I just took, send it to the work group, and note the date”—into a verifiable sequence of device operations: open the gallery, select the target, invoke the compression capability, switch to the messaging app, locate the conversation, fill in the note, and send. Systems of this kind are commonly called mobile agents or device-operation agents: a large language model serves as the core for planning and understanding, while the system-accessible UI and interfaces serve as the execution layer, completing a cross-app, cross-page task loop within an authorized scope.
For developers and enterprises, the pain point is not merely whether the model is “smart enough.” Three things must hold at the same time: instruction understanding must be stable, the operation path must be replayable and auditable, and inference should stay as close to the device as possible to reduce latency and privacy exposure. The sections below cover capability boundaries, system layering, execution mechanisms, deployment forms, and engineering practices, using industry-standard concepts and avoiding any binding to a specific product form.
Capability Boundaries: Semantics, Orchestration, and Localization
Semantic understanding is more than intent classification. In mobile scenarios, the same sentence may map to different apps, different page states, and different permissions. The model must simultaneously handle the user’s goal, the currently visible UI information (control tree, text, icon semantics), whether prior steps succeeded, and how to revise the plan after a failure. In practice, it helps to model “task-level intent” and “step-level action” separately, avoiding the generation of one long, unrecoverable script.
Cross-app operation is where the value lies—and where the risk lies. When there is no unified business interface across messaging, gallery, files, browser, and system settings, the agent can only rely on general-purpose means such as accessibility services, input injection, screenshot understanding, and control localization. Engineering-wise, separate “can be tapped” from “is allowed to be tapped”: the former is a capability, the latter is a policy. Cross-app orchestration must also handle app cold starts, interrupting dialogs, expired login sessions, and dynamically changing controls, so the executor must be a state machine rather than a one-shot script.
On-device deployment addresses latency, weak networks, and keeping sensitive data on the device. A small-to-medium language model on the device can handle planning and UI understanding, while the cloud intervenes only for complex reasoning or when knowledge is insufficient. The key is tiering: which tokens must be processed locally (screen content, account-related text) and which can go to the cloud (general knowledge, long plans). Cloud capabilities such as object storage, logging services, and monitoring/alerting are well suited to holding audit trails and model version management—rather than syncing full-screen pixels to a remote server by default.
System Layering: A Deployable Architecture from Instruction to Action
A maintainable framework is typically divided into five layers.
The perception layer collects the currently actionable view: control tree, screenshot, foreground package name, focus, and dialog stack. Collection should be minimal and necessary, avoiding full-screen recording as the default. Sensitive pages (payment, lock screen, CAPTCHA) should be hard-blocked.
The understanding layer aligns natural language with the current perception and outputs a structured task graph: goal, constraints, success conditions, and forbidden actions. This is where function-call-style output (action name, parameters, expected UI change) fits well, rather than free-text “suggestions” that leave the user to tap things themselves.
The planning layer expands the task graph into ordered steps and reserves branches for timeouts, missing controls, denied permissions, and manual user interruption. Planning should be interruptible and resumable, and step granularity should err on the finer side to make failure localization easier.
The execution layer maps abstract actions to system capabilities: tap, swipe, input, back, wait for UI stability, and app switching. Execution must be idempotency-friendly: side effects from repeated taps must be detectable. Input operations should follow a secure-keyboard policy to avoid plaintext logs.
The governance layer covers permissions, auditing, rate limiting, and human confirmation. High-risk actions (uninstalling, bulk deletion, external sending, changing system settings) should require secondary confirmation or a whitelist. Logs should record “what was done and which piece of UI evidence justified it,” not the full screen content.
A sample action protocol can be thin, keeping device and cloud consistent:
{"action": "tap","selector": {"type": "text", "value": "Send"},"expect": {"timeout_ms": 2000, "contains_text": "Sent"},"on_fail": "replan"}
The point of the protocol is verifiable expectations, not a flashy variety of action types.
Turning Natural Language into an Operation Sequence: Planning and Verification
The reliable path is generally “plan first, then execute, verifying as you go.” The model produces a short plan, and after each step the UI diff is checked against the expectation. If the expectation is not met, replan locally rather than tearing down the whole sequence. UI understanding can use a multimodal model on screenshots, or a control tree to reduce computation; the two are complementary—the control tree is stable, while screenshots cover custom-drawn controls.
For cross-app tasks, explicitly maintain a “current app—current page—key controls” triple as planning context. Overly long context drags down on-device inference, so summarization is needed: keep only the recent successful/failed steps relevant to the goal. For repetitive tasks (daily report forwarding, gallery organization), you can distill templates; templates take priority over planning from scratch each time, saving compute and improving predictability.
Evaluation should not look only at “did the task finish tapping.” Measure separately: intent-parsing accuracy, step success rate, average number of steps, human takeover rate, and sensitive-misoperation rate. The last should carry more weight than the first. A smooth demo does not equal production readiness.
Device-Cloud Collaboration and Resource Constraints
On-device agents are constrained by memory, power, and heat. A common approach: a small model stays resident for routing and simple actions, a slightly larger model loads on demand for complex planning; UI encoding is compressed before entering the model; and decoding caps the maximum number of steps to prevent infinite loops. The cloud is suited to hard-case distillation, policy updates, and compliance-rule distribution. Container platforms can host evaluation and regression; message queues can asynchronously return desensitized failure samples; and monitoring/alerting should watch for abnormal step counts, spikes in permission denials, and crashes in specific apps.
On security, hold firm: deny unknown actions by default; app-level authorization must be revocable; align enterprise scenarios with MDM policies; and model output must pass schema validation before entering the executor—never allow free-form code to be evaluated on the device.
Engineering Checklist
In the requirements phase, define the task domain first. It is better to first get three high-frequency paths working—gallery, messaging, and files—before discussing general roaming. For data, build a regression set from synthetic UIs and desensitized recordings, covering dialogs, orientation changes, and dark mode. Testing should treat “the model was right but the control changed” as a first-class case, using multi-strategy selectors (text, description, relative position) to reduce fragility. For release, use capability switches and canary rollouts, with the ability to degrade to a read-only suggestion mode with one action when problems arise.
The direct benefit for readers is turning a “chat-capable assistant” into a “governable operation loop”—clear layering, verifiable actions, circuit-breakers for sensitive paths, and an explicit device-cloud division of labor. This way, even as the underlying model iterates, the execution and governance assets remain reusable—and that is the part of a mobile AI assistant framework that can truly scale.
