---
title: "Checkpoint what is already done"
lesson_id: "02"
---

# Checkpoint what is already done

- **Lesson ID:** 02
- **Goal:** Define a Codable checkpoint and an atomic file store.
- **Human lesson:** [02-checkpoint-progress.html](02-checkpoint-progress.html)

## Prerequisites

Lesson 01.

## Inputs, outputs, and artifacts

- **Inputs:** Step name, prompt, outputs, optional transcript bytes.
- **Outputs:** A file in the app container.
- **Artifacts:** WorkflowCheckpoint and CheckpointStore sketches.

## Agent build steps

1. Write after every successful step.
2. Use an atomic write.
3. Redact before persist. Confirm Transcript encode names in the SDK.
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

- A checkpoint holds id, step, prompt, plan, gathered facts, decision, and transcript data.
- Write after every successful step, before the next model call.
- Save JSON atomically in the app container.
- Redact before persist. Avoid secrets in backup-eligible files.

## Takeaways

- A step is not done until the checkpoint file exists.
- Persist step fields and transcript when the next call needs conversation context.
- An atomic write prevents half JSON if the process dies mid-save.

## Acceptance checks

- Checkpoint is Codable.
- Atomic write is named.
- Sibling links, progressive .flow diagrams, and the Agent brief link are present.
- [ ] Proceed to [lesson brief](03-resume-after-retry.llms.md).
