Skip to content

SwarmMulti-Agent Workflows for Swift

Chain LLMs, tools, and memory into production workflows -- with compile-time safety, crash recovery, and on-device inference.

Install

swift
.package(url: "https://github.com/christopherkarani/Swarm.git", from: "0.3.4")

Quick Start

swift
import Swarm

@Tool("Looks up the current stock price")
struct PriceTool {
    @Parameter("Ticker symbol") var ticker: String
    func execute() async throws -> String { "182.50" }
}

let agent = try Agent(
    "Answer finance questions using real data.",
    configuration: .default.name("Analyst"),
    inferenceProvider: .anthropic(key: "sk-...")
) {
    PriceTool()
}

let result = try await agent.run("What is AAPL trading at?")

Multi-Agent Workflow

swift
let result = try await Workflow()
    .step(researchAgent)
    .step(writerAgent)
    .run("Write about Swift concurrency.")

How Swarm Compares

SwarmLangChainAutoGen
LanguageSwift 6.2PythonPython
Data race safetyCompile-timeRuntimeRuntime
On-device LLMFoundation Models----
Execution engineCompiled DAGLoop-basedLoop-based
Crash recoveryAuto checkpoints--Partial
Type-safe tools@Tool macroDecoratorsRuntime
StreamingAsyncThrowingStreamCallbacksCallbacks
iOS / macOSFirst-class----

Released under the MIT License.