---
title: "Debug and ship the loop"
lesson_id: "05"
---

# Debug and ship the loop

- **Lesson ID:** 05
- **Goal:** Show mode in the UI, keep a replayable log, and pass a short ship gate.
- **Human lesson:** [05-debug-and-ship.html](05-debug-and-ship.html)

## Prerequisites

- Lesson 04 orchestrator.

## Inputs, outputs, and artifacts

- **Inputs:** A finished run.
- **Outputs:** On-screen mode, StepRecord log, ship checklist.

## Agent build steps

1. Show current mode in the UI.
2. Log mode, route, tools, blocked moves, leftover tokens.
3. Keep records on device and redact shared note text.
4. Test a blocked transition, a cap stop, and a visible review before an external write.
5. Confirm no LangChain and one active Profile.
6. 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 em dashes. iOS 27 and macOS 27.

## Key concepts

- Show current mode in the UI. Log each step.
- Record mode, route key, tool names, blocked transitions, and leftover tokens.
- Ship gates: blocked transitions logged, cap stops runaway loops, review before external writes.
- Keep records on device. Redact note text in shared logs.

## Takeaways

- Refuse to ship a loop you cannot replay from the log.
- Store the route key from the model router on the same step record.
- One Profile active. No LangChain runtime in the project.

## Acceptance checks

- Ship gates are listed.
- StepRecord is shown.
- Agent brief link is present.
