Framework designed for building AI agents with tool interaction, complex workflows, semantic search, and persistent memory. Offers modular architecture, real-time processing, and comprehensive tracing.
Koog is a Kotlin-based framework designed to build and run AI agents entirely in idiomatic Kotlin and Java API. It lets you create agents that can interact with tools, handle complex workflows, and communicate with users.
Key features
Key features of Koog include:
Available LLM providers and platforms
The LLM providers and platforms whose LLMs you can use to power your agent capabilities:
Google
OpenAI
Anthropic
DeepSeek
OpenRouter
Ollama
Bedrock
Quickstart example
To help you get started with AI agents, here is a quick example:
funmain() = runBlocking {
// Before you run the example, assign a corresponding API key as an environment variable.val apiKey = System.getenv("OPENAI_API_KEY") // or Anthropic, Google, OpenRouter, etc.val agent = AIAgent(
promptExecutor = MultiLLMPromptExecutor(OpenAILLMClient(apiKey)), // or Anthropic, Google, OpenRouter, etc.
systemPrompt = "You are a helpful assistant. Answer user questions concisely.",
llmModel = OpenAIModels.Chat.GPT4o
)
val result = agent.run()
println(result)
}
Using in your projects
Supported targets
Currently, the framework supports the JVM, JS, WasmJS and iOS targets.
Requirements
JDK 17 or higher is required to use the framework on JVM.
Kotlin 2.3.10 or higher should be set explicitly in existing projects. Please check the libs.versions.toml to know more about Kotlin dependencies (currently it uses kotlinx-coroutines 1.10.2, kotlinx-serialization 1.10.0 and kotlinx-datetime 0.7.1)
Multiplatform development: Deploy agents across JVM, JS, WasmJS, Android, and iOS targets using Kotlin Multiplatform.
Reliability and fault-tolerance: Handle failures with built-in retries and restore the agent state at specific points during execution with the agent persistence feature.
Intelligent history compression: Optimize token usage while maintaining context in long-running conversations using advanced built-in history compression techniques.
Enterprise-ready integrations: Utilize integration with popular JVM frameworks such as Spring Boot and Ktor to embed Koog into your applications.
Observability with OpenTelemetry exporters: Monitor and debug applications with built-in support for popular observability providers (W&B Weave, Langfuse).
LLM switching and seamless history adaptation: Switch to a different LLM at any point without losing the existing conversation history, or reroute between multiple LLM providers.
Integration with JVM and Kotlin applications: Build AI agents with an idiomatic, type-safe Kotlin DSL designed specifically for JVM and Kotlin developers.
Model Context Protocol integration: Use Model Context Protocol (MCP) tools in AI agents.
Agent Client Protocol integration: Build ACP-compliant agents that can communicate with standardized client applications using the Agent Client Protocol (ACP).
Knowledge retrieval and memory: Retain and retrieve knowledge across conversations using vector embeddings and RAG.
Powerful Streaming API: Process responses in real-time with streaming support and parallel tool calls.
Modular feature system: Customize agent capabilities through a composable architecture.