Features

Everything the SDK
gives you.

Each feature shipped as part of the v0.5 surface — production-ready, fully typed, and documented in the GitHub README.

01 · providers

Multi-Provider Support.

Anthropic, OpenAI, Ollama, and GLM behind a single AgentOptions surface. Swap the provider — the rest of your agent code stays identical.

swift
// Anthropic
let agent = createAgent(options: AgentOptions(
    provider: .anthropic,
    apiKey: ProcessInfo.processInfo.environment["ANTHROPIC_API_KEY"]!,
    model: "claude-sonnet-4-6"
))

// OpenAI
let agent = createAgent(options: AgentOptions(
    provider: .openai,
    apiKey: "sk-...",
    model: "gpt-4o"
))

// Ollama (local)
let agent = createAgent(options: AgentOptions(
    provider: .ollama,
    baseURL: "http://localhost:11434",
    model: "llama3.1"
))

02 · streaming

Streaming & Events.

Subscribe to partial text, tool invocations, and final results as a typed AsyncStream. Drive UI updates token-by-token.

swift
for await event in agent.stream("Summarize this PDF") {
    switch event {
    case .partial(let delta):
        print(delta, terminator: "")
    case .toolUse(let call):
        print("→ \(call.name)(\(call.args))")
    case .result(let final):
        print("\n✓ \(final.text)")
    }
}

03 · tools

Custom Tools.

Declare tools with defineTool. Inputs are validated against a Codable schema, outputs are passed straight back to the model.

swift
let weather = defineTool(
    name: "get_weather",
    description: "Get current weather for a city",
    inputSchema: WeatherInput.self
) { input in
    let temp = try await fetchWeather(city: input.city)
    return ToolResult(content: "\(temp)°C in \(input.city)")
}

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

04 · mcp

MCP Integration.

Connect to Model Context Protocol servers over stdio or SSE. Tools and resources from the server become available to your agent automatically.

swift
let agent = createAgent(options: AgentOptions(
    apiKey: "sk-...",
    model: "claude-sonnet-4-6",
    mcpServers: [
        .stdio(
            name: "filesystem",
            command: "npx",
            args: ["-y", "@modelcontextprotocol/server-filesystem", "/tmp"]
        ),
        .sse(
            name: "remote",
            url: URL(string: "https://example.com/mcp")!
        )
    ]
))

05 · hooks

Hook System.

Intercept tool execution with preToolUse and postToolUse hooks. Add audit logs, guards, retries, telemetry — without changing your tool code.

swift
let agent = createAgent(options: AgentOptions(
    apiKey: "sk-...",
    model: "claude-sonnet-4-6",
    hooks: AgentHooks(
        preToolUse: { call in
            log("→ \(call.name) \(call.args)")
            if call.name == "delete_file" { return .deny("not allowed") }
            return .allow
        },
        postToolUse: { call, result in
            metrics.record(tool: call.name, ms: result.duration)
        }
    )
))

06 · budget

Permission & Budget Control.

Cap tokens, cost, and step count per run. Permission policies decide which tools an agent may call. Stop runaway agents before they cost you.

swift
let result = try await agent.run(
    "Refactor this module",
    budget: RunBudget(
        maxTokens: 50_000,
        maxCostUSD: 0.50,
        maxSteps: 30
    ),
    permissions: PermissionPolicy(
        allowedTools: ["read_file", "write_file"],
        deniedTools: ["shell_exec"]
    )
)

07 · evolution

Self-Evolution.

The SDK learns from every session. ExperienceExtractor pulls structured signals from conversations, SkillEvolver adapts skills based on usage, and ReviewOrchestrator runs background review pipelines automatically.

swift
// Extract experience from a session
let extractor = LLMExperienceExtractor(client: myLLMClient)
let result = try await extractor.extract(
    from: messages, config: ExtractionConfig()
)
for signal in result.signals {
    try await factStore.save(signal: signal)
}

// Evolve a skill based on usage
let evolver = LLMSkillEvolver(client: myLLMClient)
let evolved = try await evolver.evolve(
    skill: mySkill, signals: usageSignals,
    config: SkillEvolutionConfig()
)

08 · agents

Sub-Agent Orchestration.

Spawn child agents for parallel work, create teams with shared task lists, and coordinate via inter-agent messaging. Build complex multi-agent pipelines.

swift
// Sub-agents, teams, and tasks
let child = try await agent.spawn(
    type: .explore, prompt: "Find all API routes"
)
let team = TeamCreate(name: "code-review")
TaskCreate(subject: "Review auth module", owner: child)
SendMessage(to: child, message: "Focus on security")

09 · server

HTTP API Server.

Expose any Agent as a REST + SSE service. Submit tasks, track runs, stream events — with auth, concurrency limits, and health checks.

swift
let server = AgentHTTPServer(
    agent: agent,
    host: "127.0.0.1", port: 4242,
    authKey: "my-secret-key",
    maxConcurrentRuns: 5
)
try await server.start()

// POST /v1/runs          → submit task (202 + run_id)
// GET  /v1/runs          → list runs
// GET  /v1/runs/{id}     → run status
// GET  /v1/runs/{id}/events → SSE stream

10 · sessions

Session Persistence.

Save, load, fork, and restore conversation transcripts as JSON. Resume an agent across processes, devices, or days.

swift
let sessionStore = SessionStore()

let agent = createAgent(options: AgentOptions(
    apiKey: "sk-...", sessionStore: sessionStore,
    sessionId: "my-session"
))

// First run — auto-saved
let r1 = await agent.prompt("Remember: I prefer Swift.")

// Resume in a new process — history is auto-loaded
let agent2 = createAgent(options: AgentOptions(
    apiKey: "sk-...", sessionStore: sessionStore,
    sessionId: "my-session"
))
let r2 = await agent2.prompt("What language do I prefer?")

11 · skills

Skills System.

5 built-in skills (Commit, Review, Simplify, Debug, Test) with custom skill registration. Package reusable behaviors and share them across projects.

swift
let registry = SkillRegistry()
registry.register(BuiltInSkills.commit)
registry.register(BuiltInSkills.review)

// Custom skill
let explainSkill = Skill(
    name: "explain",
    description: "Explain code in detail",
    promptTemplate: "Read the files and explain...",
    toolRestrictions: [.bash, .read, .glob, .grep]
)
registry.register(explainSkill)

12 · memory

Enhanced Memory.

Fact-based memory with candidate → active → retired lifecycle. Evidence-driven confidence scoring. Import and export memory across sessions.

swift
// Memory with lifecycle and confidence
let fact = Fact(
    content: "User prefers MVVM architecture",
    source: .session,
    confidence: 0.92
)
try await factStore.add(fact)

// Auto-compaction for long conversations
let agent = createAgent(options: AgentOptions(
    apiKey: "sk-...",
    autoCompact: true  // stays within context limits
))