https://github.com/tom-ryder/agentrunkit
Lightweight Swift 6 framework for building LLM-powered agents — cloud + on-device inference via MLX on Apple Silicon
https://github.com/tom-ryder/agentrunkit
agent-framework ai-agents anthropic apple-silicon function-calling generative-ai ios llm local-llm macos mcp mlx model-context-protocol multimodal ollama on-device-ai openai openrouter swift tool-calling
Last synced: 13 days ago
JSON representation
Lightweight Swift 6 framework for building LLM-powered agents — cloud + on-device inference via MLX on Apple Silicon
- Host: GitHub
- URL: https://github.com/tom-ryder/agentrunkit
- Owner: Tom-Ryder
- License: mit
- Created: 2026-01-17T04:02:53.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2026-04-02T17:40:53.000Z (16 days ago)
- Last Synced: 2026-04-03T03:34:09.888Z (15 days ago)
- Topics: agent-framework, ai-agents, anthropic, apple-silicon, function-calling, generative-ai, ios, llm, local-llm, macos, mcp, mlx, model-context-protocol, multimodal, ollama, on-device-ai, openai, openrouter, swift, tool-calling
- Language: Swift
- Size: 1.36 MB
- Stars: 15
- Watchers: 1
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# AgentRunKit
A lightweight Swift 6 framework for building LLM-powered agents with type-safe tool calling.
Zero dependencies · Full Sendable · Async/await · Cloud + Local · MCP
---
## Quick Start
```swift
import AgentRunKit
let client = OpenAIClient(apiKey: "sk-...", model: "gpt-5.4", baseURL: OpenAIClient.openAIBaseURL)
let weatherTool = try Tool(
name: "get_weather",
description: "Get the current weather"
) { params, _ in
"72°F and sunny in \(params.city)"
}
let agent = Agent(client: client, tools: [weatherTool])
let result = try await agent.run(userMessage: "What's the weather in SF?", context: EmptyContext())
if let content = result.content {
print(content)
}
```
`result.content` is optional. Completed runs return finish-tool content, while structural terminal reasons such as max iterations or token budget exhaustion surface through `result.finishReason` with no final content.
---
## Documentation
Full documentation including guides and API reference is available on [Swift Package Index](https://swiftpackageindex.com/Tom-Ryder/AgentRunKit/documentation/agentrunkit).
---
## Installation
Add to your `Package.swift`:
```swift
dependencies: [
.package(url: "https://github.com/Tom-Ryder/AgentRunKit.git", from: "1.20.1")
]
```
```swift
.target(name: "YourApp", dependencies: ["AgentRunKit"])
```
For on-device inference, additional targets are available:
- `AgentRunKitMLX` for MLX on Apple Silicon (requires [mlx-swift-lm](https://github.com/ml-explore/mlx-swift-lm) as a dependency)
- `AgentRunKitFoundationModels` for Apple Foundation Models (iOS 26+ / macOS 26+, no external dependencies)
---
## Features
- Agent loop with configurable iteration limits and token budgets
- Streaming with `AsyncThrowingStream` and `@Observable` SwiftUI wrapper
- Type-safe tools with compile-time JSON schema validation
- Sub-agent composition with depth control and streaming propagation
- Context management: automatic compaction, pruning, token budgets
- Structured output with JSON schema constraints
- Multimodal input: images, audio, video, PDF
- Text-to-speech with concurrent chunking and MP3 concatenation
- MCP client: stdio transport, tool discovery, JSON-RPC
- Extended thinking / reasoning model support
---
## Providers
| Provider | Description |
|----------|-------------|
| `OpenAIClient` | OpenAI and compatible APIs (OpenRouter, Groq, Together, Ollama) |
| `AnthropicClient` | Anthropic Messages API |
| `GeminiClient` | Google Gemini API |
| `VertexAnthropicClient` | Anthropic models on Google Vertex AI |
| `VertexGoogleClient` | Google models on Vertex AI |
| `ResponsesAPIClient` | OpenAI Responses API with same-substrate continuity replay |
| `FoundationModelsClient` | Apple on-device (macOS 26+ / iOS 26+) |
| `MLXClient` | On-device via MLX on Apple Silicon |
---
## Requirements
| Platform | Version |
|----------|---------|
| iOS | 18.0+ |
| macOS | 15.0+ |
| Swift | 6.0+ |
| Xcode | 16+ |
---
## License
MIT License. See [LICENSE](LICENSE) for details.