« All posts

Swarm: A New Framework for Multi-Agent Workflows in Swift

Swarm is a multi-agent framework that provides compile-time security with Swift 6.2, offering an alternative to LangChain. It provides type-safe tools and crash recovery.

Swarm is an open-source Swift framework for building single- and multi-agent workflows. It lets developers chain agents using operators like .step(), .parallel(), and .route() to form DAG-based pipelines, with checkpointing that allows workflows to resume after a crash. Swift 6.2's StrictConcurrency is enabled throughout the package, so data-race issues are caught at compile time rather than runtime.

A key feature is the @Tool macro, which generates JSON schemas from Swift structs at compile time, making tool definitions type-safe compared to LangChain's runtime decorators. Swarm unifies providers—including Apple's on-device Foundation Models, Anthropic, OpenAI, Ollama, Gemini, MiniMax, OpenRouter, and MLX—under a single abstraction, with support for swapping providers at runtime.

The framework also includes AsyncThrowingStream-based streaming, semantic/vector memory, input/output guardrails, MCP tool bridging, and observability hooks. A deterministic capability showcase ships in-repo for CI-safe testing. Overall, Swarm gives iOS/macOS developers a way to build native, type-safe, concurrency-safe agent systems without relying on the Python-centric agent ecosystem.