← All courses ← Course home

Lesson 01 of 05

Why long jobs die

A LanguageModelSession lives in memory. Backgrounding, a cancel, or process death will drop a long job unless you saved the steps.

Agent brief (llms.md)

Environment setup

Use Xcode 27. New SwiftUI app, iOS 27 or macOS 27. Add Foundation Models. On iOS, you will later add Background Tasks in Signing and Capabilities.

xcodebuild -version
# New App, SwiftUI, iOS 27 or macOS 27. Add FoundationModels.
# iOS: Signing & Capabilities > Background Modes / Background Tasks as needed.

A long agent job is a list of steps. Plan. Call a tool. Judge. Call another tool. That list can take longer than the user stays in the app. If you keep the work only in a live LanguageModelSession, three events throw it away.

BackgroundApp is no longer first
CancelUser or OS stops respond
DeathProcess is gone

The session object lives in memory. Apple now lets you read and write transcript when isResponding is false. That helps you save a conversation. It does not write the file for you. It does not finish a tool after the process is gone.

MemorySession, until exit
DiskCheckpoint you wrote
New launchNew session plus restore

An Edge FDE treats a long job as a workflow with saved steps. The model fills a step. The engine records that the step is done. If the app returns, the engine starts at the next step. Read Make several agents agree first, Talk to tools with MCP, and Stop prompt attacks and leaks if a step is a vote, a tool list, or a prompt that must be redacted before you save it.

Rule. If the only copy of progress is the live session, backgrounding will restart the job.

Next, write the checkpoint you store on disk.

Key concepts

  • Long agent jobs are step lists: plan, tool, judge, tool.
  • Three stop points are background, cancel, and process death.
  • The session and transcript live in memory until you persist them.
  • Reading the transcript does not auto-save to disk.

Takeaways

  • If the only copy of progress is the live session, backgrounding restarts the job.
  • The engine records finished steps and starts at the next one.
  • Disk checkpoint plus a new session on relaunch is the durable pattern.