PiDurableKit is an open-source Swift package for building durable AI agents on Apple platforms. It wraps the pi-durable agent runtime through JavaScriptCore and exposes a Swift API for iPhone, iPad, Mac, Apple TV, and Vision Pro apps. The important design choice is persistence before display: conversations, model turns, tool calls, durable tasks, and custom state are committed to storage before the user sees results. If iOS kills an app during a model turn, the app can reopen the storage and continue from the recorded work instead of losing the session.
The README shows a Swift-first developer experience. Builders create a Models object, store API keys in the Keychain, open a Harness backed by SQLite, JSONL, or in-memory storage, create a root conversation, submit messages, and wait for settled results. The API mirrors pi-durable concepts while using Swift concurrency. It supports Swift tools, system-prompt sections, hooks, wraps, subagents, child tasks, atomic transactions, streaming conversation views for SwiftUI, coding-agent style events, steering, follow-ups, abort, reset, compaction, forks, typed documents, entries, usage, and cost data.
PiDurableKit is especially useful for app developers who want agents inside native Apple software rather than in a web app or terminal-only harness. A productivity app can persist multi-step assistant work. A developer tool can let a model call Swift closures and recover after an app lifecycle interruption. A Vision Pro or iPad workflow can stream durable conversation state into SwiftUI while keeping provider tokens in the Keychain. The package lists provider support through pi-ai, including Anthropic, OpenAI, Google, OpenRouter, Groq, xAI, Mistral, and compatible servers. It also mentions OAuth sign-in to Claude Pro or Max, ChatGPT, GitHub Copilot, and OpenRouter, with automatic token refresh.
The project is infrastructure, not a finished user-facing assistant. Builders still need to define agents, tools, prompts, storage policy, model choices, and UI. They also need to test recovery behavior under real mobile lifecycle events. The repository uses CC0-1.0 licensing, so the public code is free to use, but downstream model APIs, provider subscriptions, and app infrastructure may still cost money.
For OpenTools users, PiDurableKit fills a clear gap: durable agent runtime primitives for Apple apps. Most agent frameworks focus on Python servers, Node services, or command-line coding agents. PiDurableKit brings persistence, subagents, tool calls, and streaming state into Swift, which makes it relevant for teams trying to build reliable AI experiences directly into native Apple products.
For production work, plan the storage model before adding complex tools. SQLite is a good default for app-local durability, while JSONL can be useful for inspectable logs and tests. Keep provider credentials in Keychain, review OAuth scopes, and expose only the actions the agent really needs. Durable agents are safer when every write has a clear owner, every tool has a narrow input schema, and every resumed task can be explained to the user.
PiDurableKit also helps with previews and automated tests. The README mentions a scripted faux provider, which lets teams exercise conversation flows without hitting paid model APIs. Use that path to test busy conversations, aborts, compaction, follow-up turns, and recovery from interrupted work before connecting real providers.