Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

AI System Design

Design a Hybrid Edge-Cloud Agent

Step 1 / 9

Learn AI system design by building an on-device agent that runs on the NPU by default and escalates hard queries to a cloud model — but where privacy, not just confidence, decides what may leave…

The whole design, in writing

Every step of the build above, written out: the problem each piece solves, the option that was taken and the ones that were not, the numbers, and how it fails in production.

The big idea

Privacy decides what leaves, not just confidence

An on-device agent can run on the NPU — fast, offline, private. But the small on-device model isn't as capable as a cloud model, so for hard queries you want to escalate. The usual framing is "escalate when the local model is unsure." That's only half the story: some data — health, private messages, keys — must never leave the device, no matter how uncertain the local model is. How do you get cloud capability without breaking that boundary?

Device / Userwants a private, capable agent
New in this step: Device / User.

We'll build the hybrid where privacy is the routing constraint that comes first: a privacy classifier gates escalation before confidence is even considered, so must-stay-local data is answered on-device even when that means a worse answer. Then confidence decides escalation for what's allowed to leave, redaction minimizes what's sent, and an audit records every decision. The confidence-cascade math itself lives in the LLM Router design; the fully-local alternative is the Edge Inference Fleet — this is the privacy-gated middle.

What the new pieces do

Device / Userclient
A phone or laptop running an on-device agent. The user wants both capability (which sometimes needs the cloud) and privacy (some data must never leave the device) — and those two goals are in tension.

Step 1 · The baseline

Send everything to the cloud

The simplest capable design: forward every query to a big cloud model. Answers are great. For an agent handling personal data on a personal device, what's the problem?

Device / UserCloud Model
New in this step: Cloud Model. · swipe to pan the diagram

An on-device agent forwards every query to a cloud model for the best answer. What's the core problem?

  1. Best answers at the cost of shipping every piece of personal data off the device. A personal agent sees health info, private messages, credentials — sending all of it to the cloud is a privacy breach the user never agreed to, and often a regulatory one, regardless of answer quality.

  2. Exactly: cloud-everything means all personal data leaves the device by default, which is a privacy and compliance failure for a personal agent, on top of being offline-fragile and costly per call. The user wanted a capable agent that respects a privacy boundary; this respects no boundary at all.

  3. Latency is secondary. The core problem is that a personal agent sends all of a user's private data off-device by default — a privacy breach independent of how fast the cloud responds.

Cloud-everything ships all of the user's personal data off the device by default — a privacy and often regulatory breach for a personal agent — while also failing offline and costing a cloud call per query. Capability came at the price of respecting no privacy boundary at all.

Why this piece earns its place

The reason to sit with a design you are about to throw away is that it is the one that actually ships first, and walking it back later is not a refactor. Data that has left cannot be recalled. It sits in the provider's request logs and outside any delete path you control — so a privacy fix only ever ships forward, and every query the old build sent is still gone. The retrofit is harder than it looks for a second reason: cloud-everything has no notion of sensitivity in its data model, because nothing ever needed one. Adding the gate later means going back and labelling categories of data the app never tracked, on a device where that context has usually already been flattened into a prompt string. The honest case for keeping the baseline is narrower than it sounds. "Those documents already sit in that vendor's cloud" is not on its own a reason to forward the query: storage and inference are separate endpoints with their own retention and their own subprocessors, often from different vendors, so the query path can cross a boundary the document store never did. What to check is whether the inference endpoint sits inside the same agreement as the store; where it genuinely does, a work-account agent over those documents gains little from the hybrid. On a personal device there is no such agreement to point at.

What the new pieces do

Cloud Modelcontrol
A large model in the cloud — more capable than the on-device model, but every query sent to it leaves the device. Escalating to it is a capability gain and a privacy cost.

Step 2 · The default

Answer on-device with the NPU model

Flip the default: a small model runs on the device's NPU and answers queries locally. Why is on-device-by-default the right foundation for a private, capable agent?

Device / Userwants a private, capable agentOn-Device ModelNPU · answers by default
New in this step: On-Device Model.

Why make the on-device NPU model the default responder instead of the cloud?

  1. They're usually less capable, not more — that's exactly why escalation exists. The reason to default to on-device isn't accuracy; it's that a local answer is private, fast, and offline-capable by construction.

  2. For the hardest queries the local model genuinely isn't enough, which is why this is a hybrid, not a fully-local design. On-device-by-default reduces cloud use dramatically but doesn't remove the need for escalation.

  3. Right: making on-device the default means most queries are answered with zero data leaving the device. Privacy, latency, offline capability, and cost all improve for the common case — and the cloud is reserved for the minority of queries that actually need it, which is where the privacy question gets interesting.

The on-device NPU model answers by default: private by construction, fast, and offline-capable. Most queries the small model can handle incur no data leaving the device, no latency, and no cloud cost — so escalation becomes the rare exception, and the privacy question narrows to just those exceptions.

Why this piece earns its place

Making the device the default responder quietly costs you your view of the system. Most traffic now leaves no server-side trace at all — that is the point — so the common case is invisible in production telemetry by construction, and every question you will want answered later has to be designed for on-device measurement up front: how often the local model is wrong, which query classes it handles badly, whether an update regressed anything. Retrofitting that means asking for data you just promised not to collect. The second consequence is that the on-device model is a shipped artifact, not a deployment. It lives on a fleet you cannot update atomically, across hardware tiers with different NPUs, so more than one model version is always answering and a behaviour change arrives as a migration rather than at a flag flip. That makes the escalation rate a property of the fleet's version mix rather than a constant — and the escalation rate is also your cloud bill and your egress volume, both forecast from a distribution you do not control.

What the new pieces do

On-Device Modelgateway
A small model running on the device's NPU. It answers most queries entirely locally — fast, offline-capable, and private by construction because nothing leaves the device.

Step 3 · The constraint that comes first

Gate escalation on privacy, before confidence

A query might be a candidate for escalation. Before deciding whether the local model is confident enough, there's a more important question. What is it, and why must it come first?

On-Device Modelanswers or routesPrivacy Classifiermay this leave the device?
New in this step: Privacy Classifier.

Before deciding whether to escalate an uncertain query, what must the agent check first?

  1. Availability matters for the mechanics of escalation, but it's not the gating question. The thing that must be checked before anything else is whether this query's data is even ALLOWED to leave the device — a constraint that availability can't override.

  2. Right: privacy is the routing constraint, and it comes before confidence. The classifier decides whether this query touches data that must never leave (health, credentials, private messages). If it does, escalation is off the table regardless of the confidence score — the agent answers locally with whatever it can. A better answer is never worth violating the privacy boundary.

  3. This is the trap. Confidence-first means an uncertain model escalates sensitive data to get a better answer — exactly the privacy violation the design exists to prevent. Confidence can only decide escalation for data that privacy has ALREADY cleared to leave.

The Privacy Classifier runs first: it decides whether the query's data may leave the device at all. Must-stay-local data (health, credentials, private messages) is answered on-device even when the model is uncertain — a better answer is never worth breaching the boundary. Only privacy-cleared queries reach the confidence decision.

Why this piece earns its place

Two operational details decide whether this ordering survives contact with production. The first is what the gate does when it is the thing that breaks — the classifier times out, crashes, or its policy fails to load on a cold start. The only safe behaviour is to answer locally and refuse escalation: a gate that fails open fails directly into the leak it exists to stop, and that default gets chosen quietly, by whoever is fixing a latency regression at three in the morning. The second is that the classifier sits on the critical path of every escalation candidate, ahead of any network call. If it is heavy enough to feel slow, someone will eventually propose running it after the confidence gate to save the work on queries that were never going to escalate — and that reordering is precisely the bug this step exists to prevent. Keep it cheap enough that the argument never starts. One scoping rule sits underneath both: what gets classified is the payload the request would actually carry, not the sentence the user typed. By the time a query reaches this gate the agent has usually gathered local context of its own — a calendar entry, the file that was open, a message thread — and classifying the typed text alone clears a harmless-looking question whose assembled context is nothing of the kind.

What the new pieces do

Privacy Classifierservice
The FIRST gate: classifies whether the query and its data are allowed to leave the device at all. Data marked must-stay-local is never escalated, regardless of how the confidence gate feels about it.

Step 4 · When to escalate

Confidence decides — for what may leave

For a query privacy has cleared to leave, now the familiar question: answer locally or escalate to the cloud? What decides, and how much of that decision does this design need to build?

On-Device Modelanswers or routesConfidence Gateescalate only if unsure
New in this step: Confidence Gate.

For a privacy-cleared query, what decides whether to answer on-device or escalate to the cloud?

  1. Correct: confidence is the escalation signal, but it operates only on the subset privacy already allowed to leave. A confident local answer stays local; an uncertain one escalates for a better answer. The detailed cascade — how to threshold confidence, calibrate it, trade cost against quality — is the LLM Router design's territory; here the key point is that this gate runs AFTER privacy, never before.

  2. Escalating every cleared query throws away the whole benefit of the on-device default — cost, latency, and unnecessary data movement all spike. Escalation should be reserved for queries the local model can't handle well, which is what confidence measures.

  3. Load-balancing is an operational concern, not the routing decision. What determines escalation is whether the local model can answer well (confidence), applied only to queries privacy has cleared.

For privacy-cleared queries, the Confidence Gate applies the standard cascade: a confident on-device answer stays local; an uncertain one escalates to the cloud for a better answer. The depth of that decision — thresholding, calibration, cost-quality trade-offs — is the LLM Router design's subject; the essential point here is that confidence runs only after privacy has already permitted the data to leave.

Why this piece earns its place

Two things about this gate are specific to running it here rather than inside a pure router. First, the threshold is not only a cost dial. Lowering it to get better answers raises the volume of data crossing the boundary, so a quality-tuning session is silently a privacy change and deserves the same review as one — which argues for the threshold living in device configuration rather than being set per request. The one exception to that — to the threshold being configuration rather than a request field — is an explicit user action: someone who taps "ask the cloud" has consented to that single escalation, which is a different event from the agent deciding by itself, and the audit has to be able to tell the two apart. It is not an exception to the ordering. That tap still arrives behind the privacy classifier, and a must-stay-local query is refused there exactly as it would be if the agent had asked. Second, this gate only ever sees the privacy-cleared subset, so everything you know about its calibration comes from a censored sample. You cannot measure how it would have behaved on the queries privacy refused, because they never reached it — and they are not a random slice, they are often the hardest ones. Say that out loud rather than reporting the number as if it covered everything.

What the new pieces do

Confidence Gateservice
Only for privacy-cleared queries: if the on-device model is confident, answer locally; if it's uncertain, consider escalating. This is the when-to-escalate decision — see LLM Router for the cascade math in depth.

Step 5 · Minimize what leaves

Redact before sending to the cloud

A query is cleared and the model is unsure, so it will escalate. Should the agent send the full context to the cloud? What's the right principle for the payload?

Cloud Modelbig, but off-deviceConfidence Gateescalate only if unsureRedactorminimize before sending
New in this step: Redactor.

When a query does escalate to the cloud, what should be sent?

  1. Sending everything maximizes both answer quality and leakage — including identifiers and unrelated private context the cloud doesn't need. "Allowed to leave" isn't "send it all"; data minimization still applies to permitted escalation.

  2. Right: data minimization. Even for data cleared to leave, you strip it to what the cloud actually needs — remove names, IDs, and unrelated private context that don't affect the answer. The cloud gets enough to help, and no more, so the privacy cost of a necessary escalation is as small as possible.

  3. A hash the cloud can't read is a context the cloud can't use to answer — that defeats the point of escalating. The goal isn't to hide the query from the model that must process it; it's to send the minimum necessary, redacting what the model doesn't need.

The Redactor strips an escalating query to the minimum the cloud model needs — removing identifiers and unrelated private context — so even permitted escalation leaks as little as possible. "Allowed to leave" is not "send everything": data minimization applies to every byte that crosses the boundary.

Why this piece earns its place

Where the redactor runs is most of the point: on the device, before the request is built. A scrubber in a cloud-side proxy has already received the data it is scrubbing, which puts the boundary on the wrong side of the network. Once it is local, two things are harder than they look. Redaction has to be judged across a session rather than per field — stripping the name out of a query whose remaining details still describe exactly one person is a pattern that matched and a minimization that failed, and the cloud sees the sequence of queries, not one message in isolation. And redaction is lossy, so its cost lands on answer quality: an over-aggressive pass returns advice that does not fit the user's situation, and what they experience is a bad agent, not a privacy win. Telling those two apart needs the before and the after side by side, and the only place that can happen is on the device, in the moment, while both still exist — what outlives it is a measurement, not the pair. So the redactor scores its own work as it runs and emits that: which categories it stripped, how much of the query survived. That verdict is the only evidence of this component you will ever hold, because the material that would let you re-judge a call later is the material you just promised nobody keeps.

What the new pieces do

Redactorservice
For queries that will escalate, strips the payload to the minimum the cloud needs — removing identifiers and unrelated private context — so even permitted escalation leaks as little as possible.

Step 6 · Verifiability

Audit every escalation decision

The agent is now making privacy-critical routing decisions continuously. How does the user (or a regulator) ever trust that the boundary is actually being respected?

On-Device Modelanswers or routesRedactorminimize before sendingEscalation Auditwhat left, and why
New in this step: Escalation Audit.

How do you make the agent's privacy boundary verifiable?

  1. "Trust the code" is not something a user or regulator can verify, and it gives you nothing to investigate if a leak is suspected. A privacy-critical system needs an auditable record of what it actually did, not just an assurance that it should behave.

  2. Escalations matter, but so do the decisions to keep data local — the record has to show what was kept on-device and why, so you can verify the boundary held for sensitive queries, not just observe what left.

  3. Right: an on-device record of every decision (escalated or kept local, and the reason) makes the privacy boundary auditable. The user can confirm sensitive queries never left, a regulator can verify compliance, and a suspected leak can be investigated — and keeping the audit on-device means the record itself doesn't become a new leak.

An on-device Escalation Audit records every routing decision — what was sent, what was kept local, and why. That makes the privacy boundary verifiable rather than merely asserted: the user can confirm sensitive queries stayed local, a regulator can check compliance, and a suspected leak is investigable — and keeping the log on-device means it doesn't become a leak of its own.

Why this piece earns its place

Build the record out of decisions, not payloads — the classification, the reason, the policy version that produced it, a digest of what was sent rather than its text — and keep it in the same encrypted store as the data it describes. The policy version earns its place: the rules will tighten, and a call made under last month's rules only reads as correct if the record says which rules were live when it was made. The log also grows forever on hardware with no spare room, so it needs a cap and a rotation rule, and the moment you choose that number you have decided how far back a dispute can be investigated: a product decision wearing storage clothing. The consequence people do not plan for arrives when you actually show the log to a user. An audit nobody reads is theatre, but a readable one constrains the classifier upstream — every decision now has to be explainable in one printable sentence, which quietly rules out any reason you cannot put into words.

What the new pieces do

Escalation Auditdata
An on-device record of every escalation decision — what was sent, what was kept local, and why — so the privacy boundary is verifiable and any leak is investigable.

The payoff

Capable when it can be, private when it must be

Put it together: an agent that answers most things instantly on-device, escalates the genuinely hard queries for a better answer — but never lets must-stay-local data leave, minimizes what does, and keeps a verifiable record of every choice.

Device / UserCloud ModelOn-Device ModelPrivacy ClassifierConfidence GateRedactorEscalation Audit
The finished design, end to end. · swipe to pan the diagram

That's the hybrid edge-cloud agent. On-device by default, privacy as the first routing gate, confidence as the second, redaction on what leaves, and an on-device audit — capability and privacy reconciled by making the boundary a hard constraint the confidence score can never override.

Everything you assembled, in order

  • On-device NPU model answers by default — private, fast, offline — so escalation is the rare exception, not the norm.
  • A privacy classifier is the FIRST gate: must-stay-local data is answered on-device even when the model is unsure — privacy is a hard constraint, not a tiebreaker confidence can override.
  • Confidence decides escalation only for privacy-cleared queries (the cascade depth lives in the LLM Router design — reused, not re-derived here).
  • A redactor minimizes what leaves — "allowed to leave" is never "send everything"; even permitted escalation sends the least necessary.
  • An on-device audit records every decision (sent vs kept local, and why), so the privacy boundary is verifiable and any leak investigable.

Where an interviewer pokes next

Getting the boxes right is the easy half. These are the questions that separate a candidate who drew the diagram from one who has run the thing. Answer each one out loud before you open it.

  1. How is this different from the LLM Router design?

    The LLM Router owns the confidence CASCADE — when a small/cheap model should hand off to a bigger one, how to threshold and calibrate confidence, how to trade cost against quality. That mechanism is reused here as the SECOND gate, but it isn't the point of this design. The distinguishing idea here is that a PRIVACY constraint sits in front of the cascade and can veto escalation outright: some data must never leave the device regardless of confidence, so routing is a privacy decision first and a capability decision second. A pure router optimizes cost/quality; this optimizes cost/quality SUBJECT TO a hard privacy boundary — a fundamentally different objective.

  2. How is it different from the fully-local Edge Inference Fleet design?

    The Edge Inference Fleet deliberately chooses to run everything on-device with NO per-query cloud fallback — its whole premise is that nothing ever leaves, accepting the on-device model's capability ceiling as the price of absolute privacy. This design is the hybrid middle: it keeps the on-device default but ADMITS escalation for the queries that genuinely need it — gated by privacy first, then confidence, then minimized. So it trades a small, controlled, audited amount of data leaving (for non-sensitive, hard queries) in exchange for breaking through the local capability ceiling when it matters. Same on-device foundation, opposite stance on whether escalation is ever allowed.

  3. Who decides what counts as "must never leave the device," and can the model be trusted to classify it?

    The classification policy is a design/product decision (often driven by data category and regulation — health, biometrics, credentials, private communications are common must-stay-local classes), not something left to the model's discretion in the moment. The privacy classifier itself should be conservative and, ideally, run with a bias toward keeping data local when uncertain — a false "keep local" costs a slightly worse answer, while a false "allow to leave" costs a privacy breach, so the asymmetry favors staying local on any doubt. It can also combine cheap deterministic signals (does this field come from a health app? is this a password field?) with a learned classifier, rather than relying on a single model judgment for a boundary this important.

  4. What about the agent's actions and memory, not just single queries — does the boundary hold across a multi-step task?

    Yes, and it's the harder case: the boundary has to be tracked across the whole workflow, not just per query, because private data read in step 1 could be smuggled into an escalated step 3. This is the same data-provenance/taint idea used in the agentic-browser gateway — a value derived from must-stay-local data stays tainted through the task, so it can never become part of a payload sent to the cloud. The on-device audit records the provenance chain, and the redactor enforces it at the escalation boundary. Single-query classification is the starting point; provenance tracking across steps is what makes it hold for a real agent.

  5. Doesn't running a capable model on the NPU plus all this routing drain the battery and the device?

    On-device inference does cost energy, but the design is actually favorable: the majority of queries are handled by a small NPU-optimized model, which modern NPUs run efficiently, and the routing services (a privacy classifier, a confidence check, a redactor) are lightweight compared to the inference itself. Escalation — the expensive-and-networked path — is reserved for the minority of hard, non-sensitive queries. Compared to the cloud-everything baseline, you trade some local compute for far fewer network round-trips and radio-on time (often the bigger battery cost), plus offline capability. The engineering care goes into picking a model sized to the device's NPU and keeping the routing checks cheap, so the common case stays energy-efficient.

Check yourself — the answers, and why

Seven steps in, these are the calls you should be able to make cold. Pick one, then read why.

  1. In a hybrid edge-cloud agent, what gates escalation FIRST?

    Privacy is a hard constraint that comes before confidence — a better answer is never worth breaching the boundary.

  2. The on-device NPU model is the default responder because…

    On-device is usually less capable, not more — the point is that local answers are private, fast, and offline, making escalation the rare exception.

  3. How does this design relate to the LLM Router's confidence cascade?

    The router owns the when-to-escalate math; here it runs only on privacy-cleared queries, downstream of the hard privacy gate.

  4. When a privacy-cleared query does escalate, the agent should send…

    Data minimization applies even to data allowed to leave: send the least that still lets the cloud help.

  5. The escalation audit is kept on-device so that…

    A privacy claim you can't verify isn't one — and an off-device audit of private decisions would defeat its own purpose.

How you’d open this design in an interview

Before any boxes: agree what it must do, pin the qualities that shape everything, then build — naming each trade-off as you make it. The walkthrough above is that exact order.

What it must do

Agree on these before drawing a single box.

  • Answer locally: handle most queries on the device’s NPU, private by construction.
  • Escalate hard queries: hand the genuinely difficult ones to a bigger cloud model.
  • Gate on privacy first: must-stay-local data never leaves, even when the model is unsure.
  • Minimize what leaves: redact an escalating query to the least the cloud needs.
  • Audit: keep an on-device record of what was sent, what stayed, and why.

The qualities that shape everything

Each one names the mechanism that buys it.

Never leak by default
Invert the cloud-everything baseline: sending data off-device is the exceptional, justified act, not the default — so the only queries that raise a privacy question are escalation candidates.
Most queries private, fast, offline
Run a small NPU model on-device as the default responder, so the common case leaks nothing, adds no latency, and works offline — escalation becomes the rare exception.
Must-stay-local data never leaves
A privacy classifier is the first gate: it decides whether the query’s data may leave at all, answering must-stay-local queries on-device even when the model is uncertain.
Cloud capability only when needed
For privacy-cleared queries, a confidence gate escalates only the ones the on-device model is unsure about — the standard cascade, run after privacy.
Even permitted escalation leaks minimally
A redactor strips an escalating query to the minimum the cloud needs, removing identifiers and unrelated private context before anything is sent.
A privacy boundary you can verify
An on-device escalation audit records every routing decision — what was sent, what stayed local, and why — kept on-device so the record isn’t itself a leak.

The trade-offs you say out loud

Senior signal isn’t the boxes — it’s naming what you gave up and why it was the right price.

On-device by default over forward every query to the cloud

Cloud-everything ships all of a user’s personal data off the device by default — a privacy and often regulatory breach — while also failing offline and costing a call per query. Answering locally makes leaving the device the exceptional, justified act.

Privacy gate before confidence over escalate whenever the model is unsure

Confidence-first means an uncertain model ships sensitive data to get a better answer — the exact violation the design exists to prevent. The privacy classifier runs first and can veto escalation outright; a better answer never outvotes the boundary.

Escalate only the uncertain over escalate every cleared query

Escalating every privacy-cleared query throws away the on-device default — cost, latency, and unnecessary data movement all spike. Confidence reserves the cloud for queries the local model genuinely can’t handle well.

Send the minimum the cloud needs over ship the full context

"Allowed to leave" is not "send it all" — the full context includes identifiers and unrelated private data the cloud doesn’t need. Redacting to the minimum makes a necessary escalation cost the smallest possible slice of privacy.

An on-device audit of every decision over trusting the code is correct

"Trust the code" is nothing a user or regulator can verify and gives nothing to investigate on a suspected leak. An on-device record of what left and what stayed makes the boundary checkable — kept local so the log isn’t a new leak.

The answer, out loud

What a strong answer to “Design a Hybrid Edge-Cloud Agent” sounds like, first question to last trade-off. It is about 7 minutes of talking; the whiteboard and the interviewer fill the rest of the 45. Read it aloud once, then close the page and give it yourself.

  1. 0-3 min

    Name the constraint before drawing anything

    I'd start by saying what makes this different from an ordinary routing problem. The user wants two things that pull against each other: capability, which sometimes means a model bigger than the device can run, and privacy, where some of what a personal agent sees — health data, private messages, credentials — should never leave the device at all. Most designs treat that second one as a preference and let a confidence score outvote it. I'd treat it as a hard constraint, and I'd say so early, because it decides the ordering of everything I'm about to draw.

  2. 3-8 min

    The obvious build is default-to-leak

    The simplest capable design forwards every query to a big cloud model, and I want to be fair to it — the answers really are better, so it isn't a strawman. What makes it the wrong default is that a personal agent sees whatever the device sees, so forwarding everything quietly puts the vendor inside the user's threat model, whether anyone meant to put it there or not. It isn't even simple, since you inherit consent screens, retention terms and region rules that the design itself does nothing to satisfy. So my first move isn't a component, it's a stance: sending data off-device becomes the exceptional act that has to be justified, not the baseline. That inversion keeps the rest of the design small: once local is the default, only escalation candidates raise a privacy question at all.

    Built in step 1: Send everything to the cloud
  3. 8-14 min

    Answer on the NPU by default

    Concretely, a small model on the device's NPU is the default responder, and anything it can handle well is answered right there. The guarantee I'm claiming for that path is structural rather than contractual: for a locally answered query there's no request for anyone to retain, which is a stronger sentence than a vendor promising not to keep one. The price is a capability ceiling on the default path, and I'd rather accept a ceiling I can describe than a boundary I can only hope holds. The other reason this step carries weight is arithmetic — it sets how rare escalation is, and rare is what makes it affordable to gate escalation carefully instead of cheaply.

    Built in step 2: Answer on-device with the NPU model
  4. 14-22 min

    Privacy is the first gate, not a tiebreaker

    This is the part I'd spend the most time on. For a query that might escalate, the first question isn't whether the model is confident — it's whether this data is allowed to leave the device at all. So a privacy classifier runs first. If the query touches a must-stay-local category, escalation is off the table and the agent answers locally with whatever it can, even knowing the cloud would answer better. That's the trade, explicitly: a worse answer over a breached boundary. And I'd flag the uncomfortable part before an interviewer does — the user feels the worse answer and never feels the leak that didn't happen, so from outside this gate looks like pure cost. That's an argument I'd expect to re-win every time someone reviews the quality numbers.

    Built in step 3: Gate escalation on privacy, before confidence
  5. 22-27 min

    Confidence decides, for what may leave

    For queries privacy has already cleared, I'd use the familiar cascade: if the on-device model is confident, keep the answer local; if it's unsure, escalate. I'd say plainly that I'm reusing it rather than deriving it — thresholding and calibration belong to the router design. What matters here is the ordering: confidence only ever operates on the subset privacy has permitted to leave. The property I'd point out here is that the cloud leg is an enhancement, not a dependency — if escalation fails or the network is gone there's already a local answer standing behind it, so offline is just the permanent version of a timeout. That falls out of having made local the default; it isn't a fallback I had to design.

    Built in step 4: Confidence decides — for what may leave
  6. 27-32 min

    Allowed to leave is not send everything

    When a query does escalate, I'd redact it first. Cleared to leave isn't the same as send it all — the full context usually carries identifiers and unrelated private detail the cloud model doesn't need in order to answer the question. So a redactor strips the payload to the minimum that still lets the cloud help. Otherwise the privacy classifier is a door rather than a boundary: pass it once and everything behind you travels.

    Built in step 5: Redact before sending to the cloud
  7. 32-38 min

    Make the boundary checkable

    The last piece is an on-device audit of every routing decision — what was sent, what stayed local, and why. The reason I want a record rather than a test suite is that this boundary can loosen without anybody noticing: a classifier update or a new data source starts clearing a category it used to refuse, and nobody ever reports a leak that worked. A log of decisions is the only place that drift becomes visible. I'd keep that record on the device: an audit of private decisions shipped to a server defeats its own purpose, because the log of what the agent saw is itself a description of the user.

    Built in step 6: Audit every escalation decision
  8. 38-45 min

    The trade-off, and what I would do next

    To close: local by default, privacy as the first gate, confidence as the second, redaction on whatever leaves, and an on-device record of all of it. The trade-off is real and permanent: queries that are both sensitive and hard get a worse answer than they could, because capability yields to the boundary and never the reverse. With more time I'd push on two things this design doesn't reach. My boundary stops at the network, so what the provider retains of an escalated payload, and whether it trains on it, is part of the guarantee and isn't mine yet — I'd want those terms beside the redactor, because they decide what a permitted escalation really costs. And I'd settle who owns the policy on a device with more than one stakeholder: a managed work profile on a personal phone, where the employer's must-stay-local list and the user's aren't the same list.

What this teaches

Learn AI system design by building an on-device agent that runs on the NPU by default and escalates hard queries to a cloud model — but where privacy, not just confidence, decides what may leave the device. Not the pure confidence cascade of an LLM router (that design owns when-to-escalate), and not the fully-local edge-inference fleet (that one never escalates): this is the hybrid where a privacy classifier is the FIRST gate, so data that must never leave the device stays local even when the on-device model is unsure — with confidence-based escalation, redaction before anything is sent, and an escalation audit.

Key takeaways

  • On-device NPU model answers by default — private, fast, offline — so escalation is the rare exception, not the norm.
  • A privacy classifier is the FIRST gate: must-stay-local data is answered on-device even when the model is unsure — privacy is a hard constraint, not a tiebreaker confidence can override.
  • Confidence decides escalation only for privacy-cleared queries (the cascade depth lives in the LLM Router design — reused, not re-derived here).
  • A redactor minimizes what leaves — "allowed to leave" is never "send everything"; even permitted escalation sends the least necessary.
  • An on-device audit records every decision (sent vs kept local, and why), so the privacy boundary is verifiable and any leak investigable.

Concepts covered

  • Privacy decides what leaves, not just confidence
  • Send everything to the cloud
  • Answer on-device with the NPU model
  • Gate escalation on privacy, before confidence
  • Confidence decides — for what may leave
  • Redact before sending to the cloud
  • Audit every escalation decision
RUN IT YOURSELF

The redaction that passes on every message and names the user by the seventh

The redactor from step 5, run over one session of escalated queries two ways — the payload judged per message, and judged against everything the cloud already holds. Every direct identifier is stripped in both; it prints how many of 8,000 people still match after each message, and the two columns end 80 apart. Change K_MIN, hit Run, and watch the per-message rule get stricter without getting any safer.

HOW TO READ THE CODE — 5 IDEAS
  1. Every fact that leaves is shared by 1,765 people or more — no single message is close to identifying anyone, which is exactly why the per-message rule clears all eight (step 5).
  2. The cloud sees the sequence, not one message, so it intersects: 2,353 → 557 → 301 → 81 → … → 1. A policy that never looks at that column cannot see it happening.
  3. Raise K_MIN to 1,500 — a floor thirty times higher — and the per-message rule still sends all eight facts and still ends at 1. Scope is the defect, not strength — the same reason the privacy classifier must score the assembled payload, not the typed sentence (step 3).
  4. The session-scoped policy holds the floor by withholding 4 of 8 facts, and 4 answers come back short a detail. That is the redaction cost step 5 says has to be measured on-device, printed as a number.
  5. The sector row narrows the set by only half, where the others cut it by three quarters: it is correlated with city. Counts here are scanned, not multiplied, so the toy cannot flatter its own headline.
CPython · WebAssembly
built so a private query stays on the device even when the edge model is unsure — make the calls, ask something sensitive, and watch it refuse to escalate.
Finished this one? 0 / 65 AI System Designs done
NextDesign a Conversational AI Closest AI system design to this one

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More AI System Designs