Swift PackageProduction-ready

Build AI agents
in Swift.

Multi-provider SDK with tools, hooks, MCP, skills, and budget control. Drop it into any Swift project — macOS, iOS, server-side — and start shipping agents.

main.swift
import OpenAgentSDK

let agent = createAgent(options: AgentOptions(
    apiKey: "sk-...",
    model: "claude-sonnet-4-6"
))

let result = await agent.prompt("Hello")
print(result.text)

Features

Everything you need to ship an agent.

Multi-Provider

One interface across Anthropic, OpenAI, Ollama, and GLM. Swap providers without touching agent code.

Streaming

Stream partial text, tool calls, and final results as async events. First token in milliseconds.

34 Built-in Tools

Core file/search/web tools, advanced task/team management, specialist cron/plan/worktree tools — ready to use.

MCP Integration

Connect to any MCP server over stdio, SSE, HTTP, or in-process. Tools and resources auto-discovered.

Hook System

20+ lifecycle events with pre/post tool hooks. Add audit logs, guards, telemetry without touching tool code.

Permission & Budget

6 permission modes plus custom policies. Token / cost budgets to stop agents before they over-spend.

Self-Evolution

Auto-extract experience from sessions, evolve skills over time, and run background review pipelines.

Sub-Agent Orchestration

Spawn child agents, manage teams and tasks, send inter-agent messages for multi-agent coordination.

HTTP API Server

Expose any Agent as a REST + SSE service with run tracking, concurrency limits, and auth.

Session & Memory

Persist and restore conversations. Fact-based memory with lifecycle, evidence-driven confidence, import/export.

Runtime Event Layer

18 typed events via EventBus — session lifecycle, agent progress, tool execution, cost tracking, and token streaming.

Smart Context

LRU file cache, Git status auto-injection, and project document discovery (CLAUDE.md/AGENT.md) — agents always know your project.

Install

Add it to your project.

Use Swift Package Manager from the command line, or add it through Xcode's package dependencies panel. Requires Swift 6.1+.

Full install guide
.package(url: "https://github.com/terryso/open-agent-sdk-swift", from: "0.6.0")

Stop wiring providers.
Start shipping agents.