Compose Workflows Fluently
Build sequential, parallel, and routed workflows with `Workflow().step(...).parallel(...).route(...)`.
Learn workflows
Chain LLMs, tools, and memory into production workflows -- with compile-time safety, crash recovery, and on-device inference.
.package(url: "https://github.com/christopherkarani/Swarm.git", from: "0.3.4")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?")let result = try await Workflow()
.step(researchAgent)
.step(writerAgent)
.run("Write about Swift concurrency.")| Swarm | LangChain | AutoGen | |
|---|---|---|---|
| Language | Swift 6.2 | Python | Python |
| Data race safety | Compile-time | Runtime | Runtime |
| On-device LLM | Foundation Models | -- | -- |
| Execution engine | Compiled DAG | Loop-based | Loop-based |
| Crash recovery | Auto checkpoints | -- | Partial |
| Type-safe tools | @Tool macro | Decorators | Runtime |
| Streaming | AsyncThrowingStream | Callbacks | Callbacks |
| iOS / macOS | First-class | -- | -- |