agent-squad-swift
What it does
This guide helps the AI build a Swift app that uses the AgentSquad framework to coordinate AI agents on the device. It is for Swift developers working on iOS or macOS apps.
When to use it
- βWhen I want to add a single AI assistant to an iPhone or Mac app written in Swift.
- βWhen I need several specialist AI agents, and a router picks the right one for each message.
- βWhen my app needs AI answers that must match live data such as prices or balances.
Skill link
https://github.com/2FastLabs/agent-squad/blob/main/swift/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agentβs skills folder.
Example of what to ask your AI
βI want to add a multi-agent AI assistant to my Swift iPhone app using AgentSquad. Where do I start?β
5 new skills a week. 1 minute to read.
How it works
The guide points the AI to the right building blocks, such as agents, a router and tools, and explains what to watch out for. It does not replace the official reference.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
AgentSquad Swift β assistant guide
Protocol-driven, on-device multi-agent framework (Swift 6.2, iOS 16+ / macOS 14+; persistence via
FileChatStorage on iOS 16+, DeviceChatStorage on iOS 17+). This is guidance and
a map β not an API reference. Read the exact signatures from the source (swift/Sources/AgentSquad/)
and the worked recipes from the docs site sources (docs/src/content/docs/swift/); this file tells
you what to use, when, and what to watch out for.
When to use what
- One assistant β an
Agent(orGroundedAgent) + anOrchestratorwith no classifier. No routing hop. - Several specialists β multiple agents + an
LLMClassifier; the orchestrator routes each turn. - Answers must not drift from data (prices, stock, balances) β
GroundedAgent: a Brain calls tools, an isolated Presenter speaks only from the curated results (it can be a smaller/local model). - Voice β a
VoiceAssistant(a peer of the orchestrator, not an agent):OpenAIVoiceAssistant(single LLM + tools, speaks directly β the spoken analog ofAgent) orOpenAIGroundedVoiceAssistant(Brain β Presenter, can't drift from data β analog ofGroundedAgent).
Every component is a Sendable protocol with one built-in implementation β swap in your own anywhere.
Modules (import only what you use)
| Import | Pulls in | Contents |
|---|---|---|
AgentSquad |
nothing external | protocols, Agent, GroundedAgent, Orchestrator, LLMClassifier, ChatCompletionsClient, DakeraRetriever, FileChatStorage, DeviceChatStorage, InMemoryChatStorage, TransformingChatStorage, SummarizingChatStorage, OSLogTracer, OTLP export |
AgentSquadMCP |
MCP Swift SDK | MCPServer (= MCPToolProvider), SDKMCPClient |
AgentSquadAudio |
AVFoundation | VoiceProcessedAudioIO (capture+playback, one engine, AEC β the recommended wiring), MicCapture (voice-processed/AEC by default), AudioPlayback, VoiceProcessing, AudioSessionPolicy (needs NSMicrophoneUsageDescription) |
SwiftPM: .package(url: "https://github.com/2FastLabs/agent-squad", branch: "main").
How a turn works
Two peer runtimes share contracts but not a control loop: a turn-based Orchestrator
(classify? β run agent β stream β persist) and a long-lived VoiceAssistant for voice. Either
way you consume an AsyncThrowingStream<AgentEvent, any Error> β the one idiom worth memorizing:
for try await event in orchestrator.route(.text("hello"), userId: "u1", sessionId: "s1") {
switch event {
case .textDelta(let token): /* stream tokens */
case .final(let message): /* the message that was persisted */
case .toolCall, .widget, .thinking, .error: break // .error is a user-facing string
}
}
.error carries a user-facing message; real programmer/transport failures throw through the
stream. .final is what the orchestrator persists. Inputs/messages are value types
(AgentInput.text, ConversationMessage, ContentPart, JSONValue) in Sources/AgentSquad/Core/.
The pieces
Orchestratordrives a turn. The classifier is optional β omit it for a single agent.Agentis one LLM with an internal tool loop.GroundedAgentis two LLMs (Brain + isolated Presenter) for answers that must stay grounded in tool results. The Presenter never sees chat history or the Brain's transcript;presenterInputpicks.questionAndData(default) or.dataOnly.ChatCompletionsClientspeaks the OpenAI wire β point itsbaseURLat OpenAI, Azure, OpenRouter, Groq, or a local Ollama/llama.cpp. ImplementLLMClientfor anything else.- Tools come from a
ToolProvider. Built-ins:ToolKitholds native tools βTool.local(Swift closure) andTool.http/Tool.get/.post(declarative HTTP, with aToolParameterDSL so you don't hand-write JSON Schema);HTTPToolGroup(baseURL:β¦)declares one API's shared config once, then one line per endpoint;MCPServer(url:)connects an MCP server; andAggregateToolProvidercomposes any mix behind one seam;DakeraRetriever(namespace:β¦)is aToolProviderbacked by a self-hosted Dakera memory server β it exposes asearch_memorytool for grounding (and a directretrieve(_:)API), talking to Dakera's REST endpoint overURLSessionwith no extra dependency. AToolResultis three-part: text β the model's context,structuredContentβ curator/UI data,
FAQ
Which Apple systems does it support?
The framework targets iOS 16 and later and macOS 14 and later.
Is this guide only for experts?
It is meant for developers who already build Swift apps and want to use this framework.
Can the agents use outside tools?
Yes, the framework supports native tools and tools provided by MCP servers.
Details
Original description by the author
Use when building or modifying a Swift app that uses the AgentSquad Swift framework β on-device multi-agent orchestration for iOS 16+ / macOS 14+: orchestrator, agents (Agent, GroundedAgent), classifier routing, LLM clients (OpenAI-compatible), tools (native + MCP), tool UIs/widgets, on-device storage, tracing, and realtime voice β built-in types and custom implementations.
repo: 2FastLabs/agent-squad
Popularity
- GitHub stars
- 7.8k
- Ranking position
- #12831
- License
- Apache-2.0
- Updated
- 10/8/2026
Comments
- β¦
More skills from this repository
agent-squad-python
7.8kHelps your agent build a Python app with the agent-squad package, a framework for coordinating several AI agents, routing requests, and sharing tools.
agent-squad-typescript
7.8kHelps your agent build Node.js apps where several AI agents work together, with routing, data storage and connections to outside tools.
Similar skills
add-model-provider
394kLets your agent connect a new AI model provider to OpenClaw using safe setup commands, keep API keys out of plain text, and run a live test.
acp-router
394kHelps your agent send a task to a coding assistant such as Claude Code or Cursor through OpenClaw, so the work runs in that tool.
browser-automation
394kTeaches your agent to control web pages step by step, including logins, tabs, and recovery when a page stops responding.