---
title: "Measure and fall back"
lesson_id: "05"
---

# Measure and fall back

- **Lesson ID:** 05
- **Goal:** Time the run and fall back only to a privacy-legal smaller path.
- **Human lesson:** [05-measure-and-fall-back.html](05-measure-and-fall-back.html)

## Prerequisites

- Lesson 04 router.

## Inputs, outputs, and artifacts

- **Inputs:** First-pick route and privacy bound.
- **Outputs:** Ordered fallback keys and a measurement log.

## Agent build steps

1. Measure on a real device.
2. Fall back from PCC to system when privacy allows.
3. Never add PCC to a mustStayOnDevice list.
4. Log first-token time and usage, including cachedTokenCount as KV cache.
5. Cite [WWDC26 241](https://developer.apple.com/videos/play/wwdc2026/241/) and [WWDC26 242](https://developer.apple.com/videos/play/wwdc2026/242/) lightly.

## Constraints

No silent public cloud. No em dashes.

## Key concepts

- Fallback order must stay legal for the privacy bound.
- Never add PCC to a `mustStayOnDevice` fallback list.
- Record time to first token, token counts, cached tokens, and a fallback flag.
- Measure on a device, not only the simulator.

## Takeaways

- If the system model is down and privacy blocks PCC, show a clear offline state.
- A route that always picks PCC drains battery.
- `cachedTokenCount` is not a semantic cache.

## Acceptance checks

- Fallback order is shown.
- Privacy cannot be bypassed.
- Agent brief link is present.
