AI Agent and On-Device Hardware: Practical Engineering for Accessible AI
This article examines the shift from model capability to system capability in AI application development, breaking a deployable system into access, orchestration, capability, data, and governance layers. It covers retrieval-augmented generation for trustworthy search and chatbots, state-machine and tool-contract design for controllable agents, the resource, latency, and safety constraints of on-device and embodied systems, hardware abstraction for AI PCs and devices, and evaluation plus cost governance. It closes with a staged rollout path for building AI applications that run reliably in real business and physical environments.
1. The Real Technical Focus: From Model Capability to System Capability
The surge in AI applications over the past two years looks like a result of stronger models, but the deeper drivers are falling inference costs and standardized service delivery, which have turned “calling intelligence” into an ordinary engineering action, similar to calling a database. The first judgment developers need to make is that competitive advantage no longer comes mainly from the model itself, but from the system capability built around it: context organization, tool invocation, state management, evaluation loops, and cost control.
A usable AI application can be broken into five layers:
- Access layer: sessions, authentication, rate limiting, and multi-device synchronization;
- Orchestration layer: task decomposition, flow control, and tool/model routing;
- Capability layer: model inference, vector retrieval, structured extraction, and code execution sandboxes;
- Data layer: document parsing, chunking, indexing, and log/feedback data return;
- Governance layer: permissions, auditing, redaction, evaluation, and cost attribution.
Most projects fail not because the model is too weak, but because two of these five layers are missing: evaluation and governance. Without evaluation, quality fluctuations cannot be traced; without governance, data and permission problems erupt after launch.
2. AI Search and Chatbots: Retrieval Augmentation Is an Engineering Problem, Not a Prompt Problem
For conversational question answering to be trustworthy, the core is making answers “sourced.” The common engineering approach is retrieval-augmented generation (RAG), but what really determines quality is the data pipeline.
Key practices:
- Prioritize document parsing: tables, formulas, and scanned documents need dedicated parsing flows, because parsing errors get amplified downstream;
- Match chunking strategy to index structure: Q&A content suits smaller granularity, while policy manuals suit preserving section hierarchy;
- Hybrid retrieval: keyword and vector retrieval complement each other; the former excels at proper nouns and IDs, the latter at semantic similarity;
- Reranking: retrieve first, then rerank, an effective way to control latency and cost;
- Citation and refusal: when evidence is insufficient, refuse or degrade to “return relevant documents,” which is an acceptable baseline for enterprise scenarios.
Illustrative code (pseudocode expressing orchestration logic rather than specific APIs):
def answer(query, user):docs = hybrid_retrieve(query, top_k=50,filters=acl_filter(user)) # permission filtering happens firstctx = rerank(query, docs)[:6]if max_score(ctx) < THRESHOLD:return {"answer": None, "refs": ctx, "mode": "refuse"}prompt = build_prompt(query, ctx, require_citation=True)return {"answer": llm(prompt), "refs": ctx}
Note that permission filtering must happen before retrieval, not after generation by “deleting sentences the user should not see”; otherwise the model has already read unauthorized content.
3. AI Agents: Controllability Comes from State Machines, Not Longer Prompts
The value of an agent is automating multi-step tasks, and the risk concentrates in accumulated multi-step errors and unpredictable tool side effects. The reliable approach is to converge free decision-making into a controlled flow:
- Explicit state machine: define the task as finite states and legal transitions, with the model only choosing an action in a given state;
- Tool contracts: each tool declares its input schema, side-effect level, timeout, and idempotency;
- Two-phase high-risk actions: first produce a “proposed execution plan,” then execute after confirmation or policy validation;
- Budget constraints: cap maximum steps, maximum tokens, and maximum execution time, aborting and reporting when exceeded;
- Replayability: record the input and output of each step to reproduce issues.
{"state": "await_confirm","action": "write_file","risk": "high","args_schema": {"path": "string", "content": "string"},"idempotent": true,"budget": {"steps": 12, "tokens": 40000}}
In engineering organization, decouple the “thinking model” from the “acting executor”: the model outputs structured decisions, and the executor validates and applies them. This way the model can be swapped while the execution chain stays stable.
4. AI Moving from the Digital World into the Physical World: Constraints of On-Device and Embodied Systems
The rise of AI glasses, AI phones, AI PCs, various AI hardware, and embodied robots is essentially about pushing inference closer to the data. On-device and physical settings bring three hard constraints that differ entirely from the cloud:
- Resource constraints: memory, power, and thermals determine model size and quantization, requiring operator-level optimization and model pruning;
- Latency constraints: interactive scenarios are sensitive to time-to-first-token and time-to-first-frame, often using a layered strategy of “on-device small model preprocessing plus cloud large model fallback”;
- Safety constraints: physical actions are irreversible, so position limits, speed limits, emergency stops, and fail-safe design are mandatory.
A general on-device/cloud collaboration rule:
if the task needs the latest knowledge or long-context reasoning:use the cloudelif latency-sensitive or unreliable network or data cannot leave the device:use on-deviceelse:on-device pre-judgment + cloud review
Embodied systems typically include four layers: perception, localization and mapping, task planning, and motion control. Large models are suited to task planning and semantic understanding, not to directly outputting high-frequency control commands; the control layer should still be handled by deterministic algorithms, and model output must pass a safety layer before becoming executable commands. On the data side, build a closed loop of “scenario collection, annotation, replay, and regression testing,” otherwise model iterations cannot be validated.
5. The Developer View of AI PCs and AI Hardware: Make Capabilities Replaceable Abstractions
When developing for multiple hardware form factors, the most common pitfall is coupling inference implementation with business logic. Define a hardware capability abstraction layer to hide compute differences:
class InferenceBackend(Protocol):def load(self, model_id: str, quant: str) -> None: ...def run(self, inputs: dict) -> dict: ...# Business code depends only on the abstraction; the backend can be an on-device runtime or a cloud service
Three foundational capabilities are also needed: distribution of models and configurations (including canary rollout and rollback), on-device logging and metrics reporting, and privacy switches (specifying which data may leave the device). In the cloud these typically map to general categories such as object storage, message queues, container platforms, logging services, and monitoring/alerting. When carried by general cloud services like Baidu AI Cloud, the focus is building “replaceability” and “observability” into the architecture rather than binding to a specific runtime.
6. Evaluation and Cost Governance: Make Quality Measurable
Without measurement there is no iteration. Build at least three layers of evaluation:
- Component level: retrieval hit rate, reranking metrics, extraction accuracy;
- End-to-end: task success rate, citation correctness, refusal appropriateness;
- Online: user feedback, manual sampling, and no regression on the regression set.
Cost governance should be designed alongside the architecture: cache reusable results, route model size by difficulty, limit context length, and precompute summaries for long documents. Attributing cost to business and scenarios is what lets you judge which features are worth optimizing.
7. Recommended Rollout Path
- Pick a high-frequency, low-risk scenario with clear acceptance criteria and close the loop;
- First connect the data pipeline and permission model, then add complex orchestration;
- Constrain agent behavior with state machines and tool contracts;
- For on-device scenarios, first decide the on-device/cloud split, then discuss model selection;
- Launch the evaluation set and monitoring/alerting before expanding features.
The real meaning of accessible AI is intelligence becoming part of the infrastructure: developers compete on data quality, system design, and governance. Solid layered architecture, controllable orchestration, on-device/cloud collaboration, and evaluation loops are what let applications run stably in real business and physical environments.
