← All courses ← Course home

Lesson 05 of 05

Debug and ship the loop

Show the current state in the UI. Keep a step log. Refuse to ship a loop you cannot replay from that log.

Agent brief (llms.md)

Put state.mode on screen. Support should see Gather, Decide, Act, Review without opening Xcode. Log each step: mode, route key, tool names, blocked transitions, leftover tokens.

UICurrent state
LogReplayable steps
CapHard stop
PrivacyNo silent PCC hop
struct StepRecord: Sendable {
    let step: Int
    let mode: Mode
    let route: String
    let tools: [String]
    let blocked: String?
    let leftoverTokens: Int?
}

Keep records on the device. Redact note text in any log you share. If you route with the Apple model router, store the route key on the same record.

Ship gates:

Sources: WWDC26 241, WWDC26 242, Foundation Models.

Done. Product can name the next step. Support can read the log. That is an EDGE FDE agent, not a demo loop.

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.