← Open Source
christopherkarani

Swarm

Type-safe tools, on-device inference, multi-agent workflows, memory, and guardrails, in one Swift-native runtime.

AI EngineeringGive agent toolsBuild agent workflow (SDK)Swift
Open on GitHub
Momentum
+0stars in 24 hours0.0%
584
Stars
44
Forks
+0
This week
9
Contributors
Created 2025-12-12 · Updated 2026-10-12 · #16571 today
Top developers
christopherkaraniobjectiveousxinnjie

christopherkarani/Swarm is ranked 16,571 with 584 stars.

Same-category comparison

christopherkarani/Swarm is ranked 16,571 among these 8 peers; ZubeidHendricks/youtube-mcp-server is ranked 16,566.

Same-category comparison
NameRankMetrics
openteams-lab/openteams16,554
Language:
TypeScript
Stars:
585
Forks:
78
HansZ8/RoboJuDo16,561
Language:
Python
Stars:
584
Forks:
84
Description:
A plug-and-play deploy framework for robots. Just deploy, just do.
IuvenisSapiens/ComfyUI_Qwen3-VL-Instruct16,562
Language:
Python
Stars:
584
Forks:
66
Description:
The successful integration of Qwen3-VL-Instruct series into the ComfyUI platform has enabled a smooth operation, supporting (but not limited to) text-based queries, video queries, single-image queries, and multi-image queries for generating captions or responses.
ZubeidHendricks/youtube-mcp-server16,566
Language:
TypeScript
Stars:
584
Forks:
141
Description:
MCP Server for YouTube API, enabling video management, Shorts creation, and advanced analytics.
KeyValueSoftwareSystems/agent-opfor16,579
Language:
TypeScript
Stars:
583
Forks:
35
Description:
Open-source adversary emulation for AI agents and MCP servers.
vivekVells/mcp-pandoc16,592
Language:
Python
Stars:
583
Forks:
62
Description:
MCP server for document format conversion using pandoc.
joeseesun/qiaomu-design16,602
Language:
JavaScript
Stars:
582
Forks:
47
omarcusdev/zap-gpt-free16,607
Language:
TypeScript
Stars:
582
Forks:
227
Description:
Este projeto explora a integração do ChatGPT com o WhatsApp, transformando o chatbot em um assistente virtual capaz de realizar tarefas como falar com amigos, responder a perguntas de clientes, e muito mais, com um toque de humanização nas conversas.
Key parameters and specifications
Key parameters and specifications
ParameterValue
LanguageSwift
CategoryAI Engineering
SubcategoryGive agent tools, Build agent workflow (SDK)
KeywordsAgent society, Agent-ready APIs, Memory management
Stars584
Forks44
Contributors9
Created date2025-12-12
Updated date2026-10-12
Stars in 1 day0
Stars in 7 days0
Rank16,571
Previous rank16,357
Rank change-214
7-day stars rank15,603
Previous 7-day stars rank15,614
7-day stars rank change11
Total stars rank17,150
Previous total stars rank17,119
Total stars rank change-31
README summary

Swarm Build production AI agents in Swift. Swarm is a Swift-native agent runtime for type-safe tools, on-device Apple Foundation Models, composable workflows, memory, guardrails, and streaming. Build for iOS, macOS, and Linux with the same agent loop. Get started · Browse examples · ⭐ Star on GitHub The example uses Apple Foundation Models on supported devices. Use an OpenAI-compatible provider, Ollama, a mock provider, or the deterministic examples when Foundation Models is unavailable. Install Add Swarm with Swift Package

Manager: The default package is lean: core Swarm, Foundation Models, and macros. Add traits for optional surfaces: Macros are enabled by default. If you want a macro-free build, use and define tools with . 2 strict concurrency, so values crossing actor boundaries must pass compiler checks. Apple Foundation Models gives supported devices an on-device inference path. When you need a local HTTP model or a cloud API, the same agent loop works with Ollama, LM Studio, OpenAI-compatible providers

, or your own provider. The macro generates tool schemas from Swift types at compile time. is available when you do not want macros. lets you chain, parallelize, route, repeat, and time out agent work. is the other composition tool: a shared notes box and helpers that each get their own brief, including when you only know how many helpers you need after an earlier step. Build a workflow Agents compose into sequential, parallel, and routed workflows: For fan-out and

routing: Providers Every agent uses a pluggable . The agent loop stays the same when you change models or deployment environments. Set a process-wide default with when you do not want to pass a provider on every agent. Sessions snapshot to portable JSON or files. | | Resilience | Retry with backoff and , circuit breakers, rate limits, chains, and tool-loop detection. | | Guardrails | Validate inputs, outputs, and tool arguments before they reach your application. | | Streaming | Observe lifecycle, tool, thinking, and output events through

. | | Resilience | Retry provider inference ( counts total attempts, minimum 1), circuit breakers, rate limits, fallback chains. | | Durable execution | Checkpoint workflow progress and resume after a process restart when the trait is enabled. | | MCP | Discover and bridge Model Context Protocol tools. | | Observability | Export agent and inference traces with OpenTelemetry or Swift logging. 2 | Foundation Models and some platform integrations are Apple-only. The Integrations memory/Membrane stack builds on Linux with portable CPU/hash backends (Metal/CoreML/MetalANNS accelerate on Apple). The

default Swarm graph is CI-tested on Ubuntu with Swift 6. Apple-only features such as Foundation Models, SwiftData, OSLog, and some built-in tool behavior are unavailable or different on Linux; use an OpenAI-compatible provider, inject a mock, or run the deterministic examples. | Design choices and architecture | | Remote Providers | OpenAI, Azure, OpenRouter, Ollama, and LM Studio | | Secret Storage | Keychain-backed API keys, redaction, checkpoint file permissions | | Foundation Models | Capture and native session modes | | Voice | Turn-based around an

existing Agent | | Durable Execution | Checkpoint and resume semantics, run inspection, fork-from-checkpoint | | OpenTelemetry Tracing | Traces and propagation | | Front-Facing

Frequently asked questions

How many stars and forks are recorded?

christopherkarani/Swarm has 584 stars and 44 forks.

What is the repository rank?

christopherkarani/Swarm is ranked 16,571.

What language and category are recorded?

christopherkarani/Swarm has 584 stars, uses Swift and belongs to AI Engineering.

Which repository is closest in rank?

christopherkarani/Swarm is compared with ZubeidHendricks/youtube-mcp-server, ranked 16,566 with 584 stars.

README

Swarm

Build production AI agents in Swift.

Swarm is a Swift-native agent runtime for type-safe tools, on-device Apple Foundation Models, composable workflows, memory, guardrails, and streaming. Build for iOS, macOS, and Linux with the same agent loop.

Get started · Browse examples · ⭐ Star on GitHub

import Swarm

@Tool("Looks up a stock price")
struct PriceTool {
    @Parameter("Ticker symbol") var ticker: String

    func execute() async throws -> String {
        "AAPL: $182.50"
    }
}

let agent = try Agent(
    "Answer finance questions using available tools.",
    configuration: .default.name("Analyst"),
    inferenceProvider: .foundationModels()
) {
    PriceTool()
}

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

The example uses Apple Foundation Models on supported devices. Use an OpenAI-compatible provider, Ollama, a mock provider, or the deterministic examples when Foundation Models is unavailable.

Install

Add Swarm with Swift Package Manager:

dependencies: [
    .package(
        url: "https://github.com/christopherkarani/Swarm.git",
        from: "0.6.6"
    )
]

The default package is lean: core Swarm, Foundation Models, and macros. Lean resolve pins swift-syntax (via the default-on Macros trait) and swift-log only — not the MCP Swift SDK or OpenTelemetry. Add traits for optional surfaces:

// Durable graph, ContextCore/Wax memory, Membrane, web helpers
.package(
    url: "https://github.com/christopherkarani/Swarm.git",
    from: "0.6.6",
    traits: ["Integrations"]
)

// MCP server adapter (SwarmMCP + MCP Swift SDK). Also enables Macros.
.package(
    url: "https://github.com/christopherkarani/Swarm.git",
    from: "0.6.6",
    traits: ["MCP"]
)

// OpenTelemetry wrappers (SwarmOpenTelemetry). Also enables Macros.
.package(
    url: "https://github.com/christopherkarani/Swarm.git",
    from: "0.6.6",
    traits: ["OpenTelemetry"]
)

Macros are enabled by default. If you want a macro-free build, use traits: [] and define tools with FunctionTool. Specifying traits replaces defaults, so combine as needed — for example traits: ["Integrations", "MCP", "OpenTelemetry"].

Why Swarm

Swarm uses Swift 6.2 strict concurrency, so values crossing actor boundaries must pass compiler checks.

Apple Foundation Models gives supported devices an on-device inference path. When you need a local HTTP model or a cloud API, the same agent loop works with Ollama, LM Studio, OpenAI-compatible providers, or your own provider.

The @Tool macro generates tool schemas from Swift types at compile time. FunctionTool is available when you do not want macros.

Workflow lets you chain, parallelize, route, repeat, and time out agent work. Job is the other composition tool: a shared notes box and helpers that each get their own brief, including when you only know how many helpers you need after an earlier step.

Need Use
Last agent's answer becomes the next agent's input Workflow
Shared notes, different briefs, N decided after a step Job

Add memory, guardrails, retries, fallbacks, streaming, tracing, MCP, and optional checkpoint/resume as your application grows.

Build a workflow

Agents compose into sequential, parallel, and routed workflows:

let researcher = try Agent(
    "Research the topic and extract key facts.",
    inferenceProvider: .foundationModels()
)

let writer = try Agent(
    "Write a concise summary from the research.",
    inferenceProvider: .foundationModels()
)

let result = try await Workflow()
    .step(researcher)
    .step(writer)
    .run("Latest advances in on-device ML")

For fan-out and routing:

let result = try await Workflow()
    .parallel([bullAgent, bearAgent, analystAgent], merge: .structured)
    .run("Evaluate Apple's Q4 earnings.")

let routed = try await Workflow()
    .route { input in
        input.contains("$") ? mathAgent : generalAgent
    }
    .run("What is 15% of $240?")

Providers

Every agent uses a pluggable InferenceProvider. The agent loop stays the same when you change models or deployment environments. Set a process-wide default with await Swarm.configure(provider:) when you do not want to pass a provider on every agent.

Provider Use it when
Apple Foundation Models You want on-device inference, OS 27 PCC via .privateCloudCompute(), image attachments, native profile sessions, owned-loop reasoningLevel, Swarm profile history seeded onto Transcript, or capture Transcript rehydration
Ollama or LM Studio You want a local HTTP model for development or private deployments
OpenAI, Azure, or OpenRouter You want a cloud model through an OpenAI-compatible API
Custom provider You need another model backend or an internal service
let local = try Agent(
    "Be helpful.",
    inferenceProvider: .openAICompatible(.ollama(model: "llama3.2"))
)

See Remote Providers for configuration and privacy details.

Examples

Copy a complete example, or run one in deterministic demo mode without API keys or Apple Intelligence:

Example Shows
OnDeviceChat Tools, streaming, and multi-turn conversation
MultiAgentPipeline Sequential and parallel workflows plus checkpoint/resume
WaxChat Durable memory and web search with Integrations
CodeReviewer A small CLI built on Swarm
cd Examples/OnDeviceChat
swift run OnDeviceChat --demo

More capabilities

Capability What it does
Conversation and memory Preserve multi-turn state with Conversation; choose conversation, sliding-window, vector, summary, or hybrid memory. Sessions snapshot to portable JSON or FileSession files.
Resilience Retry with backoff and Retry-After, circuit breakers, rate limits, FailoverProvider chains, and tool-loop detection.
Guardrails Validate inputs, outputs, and tool arguments before they reach your application.
Streaming Observe lifecycle, tool, thinking, and output events through AsyncThrowingStream.
Resilience Retry provider inference (maxAttempts counts total attempts, minimum 1), circuit breakers, rate limits, fallback chains.
Durable execution Checkpoint workflow progress and resume after a process restart when the Integrations trait is enabled.
MCP Discover and bridge Model Context Protocol tools.
Observability Export agent and inference traces with OpenTelemetry or Swift logging.

Requirements

Platform Minimum
Swift 6.2+
iOS / macOS / tvOS 26.0+
Linux Ubuntu 22.04+ with Swift 6.2

Foundation Models and some platform integrations are Apple-only. The Integrations memory/Membrane stack builds on Linux with portable CPU/hash backends (Metal/CoreML/MetalANNS accelerate on Apple). The default Swarm graph is CI-tested on Ubuntu with Swift 6.2. Apple-only features such as Foundation Models, SwiftData, OSLog, and some built-in tool behavior are unavailable or different on Linux; use an OpenAI-compatible provider, inject a mock, or run the deterministic examples.

To configure one provider globally for the default graph:

await Swarm.configure(provider: myProvider)

Documentation

Guide Covers
Getting Started Installation and first agent
Why Swarm? Design choices and architecture
Remote Providers OpenAI, Azure, OpenRouter, Ollama, and LM Studio
Secret Storage Keychain-backed API keys, redaction, checkpoint file permissions
Foundation Models Capture and native session modes
Voice Turn-based VoiceSession around an existing Agent
Durable Execution Checkpoint and resume semantics, run inspection, fork-from-checkpoint
OpenTelemetry Tracing Traces and propagation
Front-Facing API Public API overview
API Catalog Complete symbol reference

Contributing

./scripts/ci/lean-build-test.sh
swiftformat Sources Tests --lint --config .swiftformat

All public types are expected to be Sendable. Bug reports and feature requests belong in GitHub Issues.

If Swarm helps you ship, star the repository and share what you built.

Community and license

Discussions · @ckarani7 · MIT License

Nearby in the ranking
Similar items