Skip to content
Skillpedia
Agents7.8k Β· #12831

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.md

Copy 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

Use this skill to help me: https://github.com/2FastLabs/agent-squad/blob/main/swift/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
Want your AI to find skills like this on its own?Install the free Skillpedia MCP: one line, and it searches 15,000+ skills before each task.Install in 1 minute β†’

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 (or GroundedAgent) + an Orchestrator with 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 of Agent) or OpenAIGroundedVoiceAssistant (Brain β†’ Presenter, can't drift from data β€” analog of GroundedAgent).

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

  • Orchestrator drives a turn. The classifier is optional β€” omit it for a single agent.
  • Agent is one LLM with an internal tool loop. GroundedAgent is 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; presenterInput picks .questionAndData (default) or .dataOnly.
  • ChatCompletionsClient speaks the OpenAI wire β€” point its baseURL at OpenAI, Azure, OpenRouter, Groq, or a local Ollama/llama.cpp. Implement LLMClient for anything else.
  • Tools come from a ToolProvider. Built-ins: ToolKit holds native tools β€” Tool.local (Swift closure) and Tool.http/Tool.get/.post (declarative HTTP, with a ToolParameter DSL 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; and AggregateToolProvider composes any mix behind one seam; DakeraRetriever(namespace:…) is a ToolProvider backed by a self-hosted Dakera memory server β€” it exposes a search_memory tool for grounding (and a direct retrieve(_:) API), talking to Dakera's REST endpoint over URLSession with no extra dependency. A ToolResult is 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

Is this skill useful?

0

Sign in to vote.

Comments

  • …

More skills from this repository

Similar skills