---
title: "Ship a tiny workflow engine"
lesson_id: "05"
---

# Ship a tiny workflow engine

- **Lesson ID:** 05
- **Goal:** Wrap load, one-step run, and persist in one engine. Publish a checklist.
- **Human lesson:** [05-mini-engine.html](05-mini-engine.html)

## Prerequisites

Lesson 04.

## Inputs, outputs, and artifacts

- **Inputs:** CheckpointStore and LanguageModelSession.
- **Outputs:** A shipping checklist for durable on-device agent work.
- **Artifacts:** WorkflowEngine sketch, checklist, and primary sources.

## Agent build steps

1. Show persistAndPause and resumeFromDisk.
2. List the seven checklist items.
3. Cite Foundation Models, [WWDC26 session 242](https://developer.apple.com/videos/play/wwdc2026/242/), and Background Tasks.
4. Link [Make several agents agree first](../on-device-multi-agent-consensus/), [Talk to tools with MCP](../on-device-mcp-server-client/), and [Stop prompt attacks and leaks](../on-device-guardrails/).

## Constraints

iOS 27 or later, or macOS 27 or later, and Xcode 27. Plain spoken English. No metaphor, quizzes, Mermaid, or em dashes. LanguageModelSession does not survive process death. Persist a checkpoint and the transcript yourself. Confirm transcript mutability and BGTaskScheduler names in the installed docs.

## Key concepts

- One actor runs one step at a time, then writes the file.
- Persist and pause when the session is not responding.
- iOS needs the Background Tasks capability and permitted identifiers.
- Side-effect steps still need a consensus gate.

## Takeaways

- Save each step, restore a new session, and tell stakeholders the user may need to reopen the app.
- Background Tasks may help on iOS. They will not finish the job for you.
- Redact before persist.

## Acceptance checks

- The engine is one place to load, run, and save.
- Primary sources and sibling links are present.

