Designing a Dual-Mode AI Assistant for Mobile: Engineering Practice
This article describes a dual-mode design for mobile AI assistants that routes each request to either a low-latency fast mode or a multi-step deep reasoning mode. It covers the trade-off between response speed and analysis quality, routing strategies, a five-layer system architecture, streaming output and timeout fallback, monitoring metrics, privacy and security measures, and an engineering checklist.
1. Background
A mobile AI assistant has to give timely and reliable answers under tight limits on screen size, network quality, and battery. User questions vary widely. Some are short, such as unit conversions or format changes, and users expect an immediate result. Others need step-by-step work, such as troubleshooting an error log or comparing several options, where users care more about a complete conclusion.
If every request goes through the same processing path, the system faces a dilemma. Using only lightweight processing leaves complex questions under-analyzed. Using only deep processing makes simple questions wait too long and wastes compute. The goal of a dual-mode design is to allocate resources according to the nature of each question, balancing response speed against analysis quality.
2. Definition and Boundaries of the Two Modes
2.1 Fast Mode
Fast mode prioritizes low latency. The system uses a shorter context, a lower output length limit, and skips multi-step intermediate reasoning where possible. It suits tasks such as factual lookup, short rewriting, summary extraction, and format conversion. The core metrics for this mode are time to first token and total completion time.
2.2 Deep Reasoning Mode
Deep reasoning mode lets the model perform multi-step intermediate reasoning before giving a conclusion. It is often used for mathematical calculation, code debugging, solution evaluation, and long document analysis. More reasoning steps increase both response time and compute cost, so the interface should show an estimated wait time and provide a way to cancel mid-process.
2.3 Comparison of the Two Modes
| Dimension | Fast Mode | Deep Reasoning Mode |
|---|---|---|
| Response latency | Low, suited to instant interaction | Higher, requires progress indicators |
| Compute cost | Low per request | High per request |
| Typical tasks | Factual Q&A, rewriting, translation | Derivation, debugging, solution comparison |
| Output characteristics | Concise and direct | Includes reasoning or step-by-step conclusions |
| User expectation | Quick answer | Willing to wait for higher quality |
3. Routing Strategy
Routing decides which mode a request enters. There are three common approaches.
- Manual selection by the user: Simple to build and predictable, but users must understand the difference between the modes, which adds effort.
- Rule-based judgment: Scores requests based on features such as query length, keywords, and conversation turns. Rules are transparent and easy to debug, but their coverage is limited.
- Lightweight classification model: Uses a small model to predict query complexity. Accuracy is typically higher, but it requires labeled data and ongoing maintenance.
In practice, teams usually adopt a hybrid strategy. The default is fast mode, users can switch modes manually at any time, and rules handle the initial decision. The reasoning behind this design is that misrouting is reversible. When a complex question is routed to fast mode, the user sees a shallow answer and can switch to deep mode with one tap to retry. Conversely, when a simple question is routed to deep mode, the user waits longer, which is a bigger loss of experience.
The pseudocode below shows a rule-based routing approach. The thresholds and keywords are examples only and should be tuned with offline evaluation data before launch. The Chinese keywords in the code are trigger terms that mean “why,” “prove,” “compare,” “derive,” and “troubleshoot.”
function choose_mode(query, user_pref, history_turns):if user_pref is "fast" or "deep":return user_prefscore = 0if length(query) > 120:score = score + 1if query contains any of ["为什么", "证明", "比较", "推导", "排查"]:score = score + 1if history_turns > 10:score = score + 1if score >= 2:return "deep"return "fast"
4. System Architecture Layers
The dual-mode system should be split into five layers by responsibility. Each layer handles its own job, which makes independent scaling and troubleshooting easier.
- Client layer: Handles input capture, the mode switch control, streaming content rendering, the cancel button, and local draft caching.
- Access gateway: Handles identity verification, rate limiting, and request parameter validation, and normalizes the mode parameter to a standard enum value.
- Inference scheduling layer: Selects the model instance based on mode, sets the maximum output length and timeout, and queues requests by priority. Deep reasoning requests consume more resources, so they should use a separate queue from fast requests.
- Session and storage layer: Stores conversation context and history summaries. For long sessions, it keeps only the most recent few turns verbatim and compresses earlier content into summaries to control context length.
- Observability layer: Collects logs, metrics, and traces, and configures alerts. Latency in deep mode usually varies more than in fast mode, so it needs its own monitoring dashboard.
Storage and queuing can be implemented with general-purpose object storage and message queue components. These components are not tied to a specific vendor, so the choice mainly depends on throughput, latency, and operating cost.
5. Streaming Output and Timeout Fallback
Streaming is a key way to reduce perceived latency. The server pushes each chunk of generated content to the client, so users see the first words within a few hundred milliseconds without waiting for the full result. In deep reasoning mode, intermediate steps can also be shown as progress updates, so users know the system is still working.
Timeout control should differ by mode. Fast mode uses a short timeout. When it expires, the system returns an error message and lets the user retry. Deep reasoning mode uses a longer timeout. When it expires, there are two options: prompt the user to keep waiting, or automatically fall back to fast mode and tell the user. Automatic fallback guarantees a result, but the interface must clearly label it so users do not mistake the output for a deep analysis.
The pseudocode below shows the basic flow for timeouts and fallback. The timeout values are examples only and should be set based on your actual latency distribution.
function answer(query, mode):time_limit = { "fast": 5, "deep": 60 }[mode] // unit: seconds, example valueresult = run_model_with_timeout(query, mode, time_limit)if result is success:return resultif mode is "deep":fallback = run_model_with_timeout(query, "fast", 5)return mark_as_degraded(fallback) // UI label: "Switched to fast answer"return error("Request timed out. Please try again later.")
6. Metrics
Once the mode design is live, metrics show whether it works. Track at least the following.
- Time to first token: P50 and P95 for each mode, to reveal the tail latency of long requests.
- Completion time: Total time from submission to the end of output, used to evaluate the waiting cost of deep mode.
- User cancellation rate: The share of users who stop output midway. A high rate usually means wait times exceed what users expect.
- Mode switch rate: The share of users who switch from fast to deep mode, or the reverse. A persistently high rate suggests routing rules are not accurate enough.
- Compute cost per request: Resource consumption by mode, used to assess the cost structure.
- Satisfaction feedback: Collected through a lightweight rating option to measure users’ view of answer quality.
Interpret metrics in light of business scenarios. For example, if a certain type of question has a high switch rate, add it as a feature in the routing rules or include targeted training data in the next model version.
7. Privacy and Security
The dual-mode system processes users’ full questions, so data security must be considered from the design stage.
- Minimal logging: Logs do not store full conversation text by default. They record only essential fields such as request ID, mode, latency, and status code.
- Sensitive data masking: Detect and mask information such as phone numbers, ID numbers, and account credentials before writing logs
