Overview
Koog is built with Kotlin Multiplatform from the ground up, enabling you to write AI agents once and deploy them across multiple platforms. The framework supports JVM, JavaScript (JS), WebAssembly (WasmJS), Android, and iOS targets.Supported Platforms
Platform Tiers
Koog follows Kotlin’s native target support tiers: Tier 1 (Fully Supported)iosSimulatorArm64- iOS Simulator on Apple SiliconiosArm64- iOS devices (iPhone, iPad)
androidTarget- Android devices and emulators
iosX64- iOS Simulator on Intel Macs
jvm- JVM-based platforms (Java 17+)js(IR)- JavaScript with IR compilerwasmJs- WebAssembly for browser and Node.js
Build Configuration
Multiplatform Module Setup
Koog uses convention plugins to standardize multiplatform configuration:Source Set Hierarchy
Koog organizes code using a hierarchical source set structure:Platform-Specific Considerations
JVM Platform
Features Available:- All core agent functionality
- OpenTelemetry integration (
agents-features-opentelemetry) - Redis caching (
prompt-cache-redis) - All LLM provider clients
- Spring Boot integration (
koog-spring-boot-starter) - Ktor integration (
koog-ktor)
- JDK 17 or higher
- Kotlin 2.1.21 or higher
Android Platform
Features Available:- Core agent functionality
- All LLM provider clients
- File-based caching
- Ktor HTTP client
- OpenTelemetry feature requires JVM (not available on Android)
- Use OkHttp client for better Android compatibility
iOS Platform
Features Available:- Core agent functionality
- All LLM provider clients
- In-memory and file-based caching
- Ktor HTTP client
JavaScript (JS) Platform
Features Available:- Core agent functionality
- All LLM provider clients
- Browser and Node.js support
- In-memory caching
WebAssembly (WasmJS) Platform
Features Available:- Core agent functionality
- All LLM provider clients
- Browser support
- Optimized binary size
- Faster startup than JS
- Smaller binary size with tree shaking
- Near-native execution speed
- Limited third-party library support
Platform Abstractions
Expect/Actual Pattern
Use Kotlin’sexpect/actual mechanism for platform-specific implementations:
HTTP Client Selection
Koog provides multiple HTTP client implementations:Feature Availability Matrix
| Feature | JVM | Android | iOS | JS | WasmJS |
|---|---|---|---|---|---|
| Core Agents | ✅ | ✅ | ✅ | ✅ | ✅ |
| Graph Strategies | ✅ | ✅ | ✅ | ✅ | ✅ |
| Tool Execution | ✅ | ✅ | ✅ | ✅ | ✅ |
| Memory Features | ✅ | ✅ | ✅ | ✅ | ✅ |
| Tracing | ✅ | ✅ | ✅ | ✅ | ✅ |
| OpenTelemetry | ✅ | ❌ | ❌ | ❌ | ❌ |
| Redis Cache | ✅ | ❌ | ❌ | ❌ | ❌ |
| File Cache | ✅ | ✅ | ✅ | ❌ | ❌ |
| In-Memory Cache | ✅ | ✅ | ✅ | ✅ | ✅ |
| Spring Boot | ✅ | ❌ | ❌ | ❌ | ❌ |
| Ktor | ✅ | ✅ | ✅ | ✅ | ✅ |
Testing Across Platforms
Run Tests on All Platforms
Platform-Specific Tests
Best Practices
1. Use Common Code First
Maximize code sharing by implementing incommonMain: