christopherkarani/Swarm

πŸ¦β€πŸ”₯ LangGraph for Swift β€” build stateful AI agent workflows natively on Apple/Linux platforms.

What it solves

Swarm is a Swift framework designed to simplify the creation of AI agents and multi-agent workflows. It addresses the lack of native, type-safe, and concurrency-safe agent frameworks for the Apple ecosystem, providing a structured way to build complex AI pipelines that can run on-device or via custom backends.

How it works

Swarm uses a graph-based execution model where developers define agents and tools. It leverages Swift 6.2's strict concurrency to ensure data race safety. The framework provides a @Tool macro to generate JSON schemas from Swift structs at compile-time, ensuring type-safe tool calling. Workflows are compiled into a Directed Acyclic Graph (DAG) and support durable checkpointing, allowing processes to resume from a specific state after a crash.

Who it’s for

It is primarily for Swift developers building AI applications for iOS, macOS, tvOS, and Linux, particularly those who want to leverage Apple's on-device Foundation Models for private, local inference without needing API keys.

Highlights

  • On-Device First: Built-in support for Apple Foundation Models for local inference.
  • Type-Safe Tooling: Uses Swift macros to ensure tools are type-safe and schemas are generated at compile-time.
  • Durable Workflows: Supports checkpointing and crash recovery to resume long-running agent tasks.
  • Native Concurrency: Fully integrated with Swift 6.2 StrictConcurrency and AsyncThrowingStream for streaming outputs.
  • Flexible Orchestration: Supports sequential, parallel, routed, and repeat-until workflow patterns.
  • Comprehensive Memory: Includes multiple memory strategies such as vector, sliding window, and summary memory.