Agent System Architecture: A Practical Guide to Device-Cloud Collaboration
This article explains how to build an agent system that runs across devices and the cloud. It covers the shift from app-centric operating systems to an intent-driven agent runtime, how to route tasks between on-device and cloud models, how to design a layered action model with state machines for cross-app execution, and how to apply human-in-the-loop authorization, confirmation, and rollback. It also discusses generative interfaces, staged rollout with observability, and the four engineering capabilities that make proactive task automation both usable and controllable.
1. From Operating Systems to Intelligent Systems: What the Paradigm Shift Means
Traditional mobile operating systems are organized around apps. Users open an app from an icon, complete tasks inside it, and the system only schedules resources and isolates processes. When the industry talks about moving “from an operating system to an intelligent system,” the technical meaning is not a kernel replacement. It is adding an intent understanding and task execution layer on top of the OS: the user states a goal, and the system breaks it into steps, selects tools, executes across apps and web pages, and asks for confirmation at key points.
This layer is commonly called the Agent Runtime. It contains at least four subsystems: an intent parser and task planner, a tool and action executor, context and memory management, and policy and compliance checks. This distinction matters because it shifts the focus of engineering investment from model capability to systems engineering. The hard parts are permission boundaries, failure recovery, observability, and staged rollout, not the accuracy of a single inference.
2. Device-Cloud Collaboration: Allocating Compute by Task Complexity
An intelligent system has to satisfy three constraints at once: latency, compute, and privacy. The common approach is a hybrid device-cloud architecture that balances all three. The core of it is routing: splitting requests by complexity, latency sensitivity, and data sensitivity.
- On-device lightweight models: handle high-frequency, low-complexity tasks such as intent classification after a wake word, short text rewriting, UI element recognition, and simple form field mapping. The advantage is no network round trip and data never leaves the device.
- Cloud large models: handle multi-step reasoning, long-document understanding, cross-app workflow planning, and complex content generation. The advantage is reasoning depth and breadth of knowledge.
- Routing layer: decides where a task runs based on task type, network status, battery level, and privacy policy, and supports a cascade strategy of “try on-device first, escalate to the cloud on failure.”
A simplified routing decision example (pseudocode that only illustrates the layered idea):
def route(task, device_state, privacy_policy):if privacy_policy.forbids_cloud(task.data_class):return ExecutionPlan(target="on_device", model="nano")if task.steps <= 2 and task.latency_budget_ms < 300:return ExecutionPlan(target="on_device", model="nano")if device_state.network == "offline":return ExecutionPlan(target="on_device", model="nano", degrade=True)return ExecutionPlan(target="cloud", model="pro")
On-device and cloud are not substitutes; they are tiers. Engineering should guarantee that the device tier is degraded but usable: when offline, it can still handle basic actions such as reminders, draft generation, and local retrieval, and it uploads the necessary logs after connectivity is restored for optimization.
3. Task Automation and Cross-App Execution: Designing the Action Layer
The key to cross-app execution is not “knowing which button to click” but a stable action abstraction. The action layer should be split into three levels:
- Semantic actions: such as “search and summarize,” “fill a form,” and “create an event.” These are produced by the planner and are independent of any specific UI.
- UI actions: such as tap, swipe, type, and select, carried out by the executor in the target app or web page.
- Atomic events: system-level events such as notifications, clipboard changes, and sensor updates, used to trigger and verify.
The planner outputs a directed acyclic graph (DAG) or a state machine, not a linear script. Real tasks are full of branches and rollbacks: a failed field validation needs a refill, a page load timeout needs a retry, and a denied permission needs termination with an explanation. The state machine below shows the basic skeleton of “confirm first, then execute, and roll back on failure”:
class TaskState:PLANNED, AWAITING_CONFIRM, RUNNING, BLOCKED, DONE, ROLLED_BACK = range(6)def step(state, event):if state == TaskState.PLANNED and event == "plan_ready":return TaskState.AWAITING_CONFIRMif state == TaskState.AWAITING_CONFIRM and event == "user_approved":return TaskState.RUNNINGif state == TaskState.RUNNING and event == "action_ok":return TaskState.DONE if event.is_last else TaskState.RUNNINGif state == TaskState.RUNNING and event in ("denied", "timeout"):return TaskState.BLOCKEDif state == TaskState.BLOCKED and event == "rollback":return TaskState.ROLLED_BACKreturn state
Web automation (often called automated browsing in the industry) has to handle uncertainty such as dynamic rendering, anti-bot measures, and CAPTCHAs. A workable approach is to prefer accessibility interfaces and structured data over image recognition, and to pause and ask on uncertain pages instead of pushing forward.
4. Human-in-the-Loop: Permissions, Authorization, and Revocability
The biggest risk of a proactive agent is being over-proactive. The industry consensus is to keep a human in the loop and turn it into concrete mechanisms:
- Explicit authorization: the agent works only within apps or domains the user has explicitly authorized, granted at the minimum necessary scope and revocable at any time.
- Pre-execution confirmation: for irreversible actions such as sending, payment, deletion, and bulk modification, the plan summary must be shown and confirmed first.
- Explainability and traceability: each execution produces a readable step log so the user can see what was done, why, and with what result.
- One-click rollback: keep snapshots or drafts for recoverable actions so a failure returns to the pre-execution state.
In code, this appears as a policy validator that statically reviews the action graph:
def validate(plan, grants):for node in plan.nodes:if node.scope not in grants:raise PermissionError(f"unauthorized scope: {node.scope}")if node.irreversible and not node.confirmed:raise ConfirmRequired(node.id)return True
5. Generative UI and Input Enhancement: Lowering Interaction Cost
The value of an intelligent system also shows up in fewer steps. Two capabilities are worth attention. One is generating UI components from user habits and the current context, such as an auto-generated information widget, which turns common paths into reusable views. The other is input enhancement, such as polishing transcribed speech, adjusting tone, and structuring content, which turns input from typing into expressing intent. Treat generated results as suggestions that users can edit or reject, and keep optimizing the acceptance rate as one of the core metrics.
6. Delivery and Evolution: Staged Rollout, Canary Release, and Observability
These capabilities span phones, watches, cars, glasses, and laptops. The delivery strategy should be “roll out in batches by maturity, release by cohort.” Recommended practices include:
- Feature flags: an independent switch per action domain, with canary release by device model, region, and account.
- Shadow mode: a new policy first only generates plans without executing, and its quality is evaluated against human results.
- Metrics loop: a dashboard combining task success rate, average steps, confirmation rate, rollback rate, on-device hit rate, and average latency, backed by logging and monitoring alerts to locate issues.
- Privacy minimization: process sensitive data on-device first, send only the necessary context to the cloud, and control redaction and retention periods.
To host the cloud side on Baidu AI Cloud, you can combine general-purpose capabilities: a container platform for inference services, object storage for models and snapshots, a message queue for task decoupling and peak shaving, and logging plus monitoring alerts for observability, forming a vendor-neutral reference architecture.
7. Conclusion
Going from a Q&A assistant to a proactive task agent means rebuilding the operating system into an orchestrable intelligent system. Success depends not on model parameters but on four engineering capabilities: routing and degradation in device-cloud collaboration, action abstraction and state machines, human-in-the-loop authorization and rollback, and canary release with a metrics loop. Get these four solid, and cross-app, cross-web task automation becomes both useful and controllable.
