JetBrains/koog

Koog is a JVM (Java and Kotlin) framework for building predictable, fault-tolerant and enterprise-ready AI agents across all platforms – from backend services to Android and iOS, JVM, and even in-browser environments. Koog is based on our AI products expertise and provides proven solutions for complex LLM and AI problems

Koog – Kotlin‑first framework for building AI agents

What it is – Koog is a JetBrains‑incubated, open‑source library that lets you write, run, and manage AI agents completely in Kotlin (or Java). It provides a type‑safe DSL and a set of runtime services (persistence, retries, observability, history compression, RAG, streaming, etc.) so you can focus on the agent logic while the framework handles the plumbing.

Why it matters – Most existing LLM‑agent toolkits are Python‑centric. Koog brings the same capabilities to the Kotlin/Java ecosystem, making it easy to embed agents in JVM‑based back‑ends, Android apps, Kotlin‑Multiplatform projects, or even WebAssembly. This opens the door for enterprises that already rely on Kotlin/Java to add LLM‑driven features without introducing a new language stack.


Core capabilities (as listed in the README)

Category Feature
Multiplatform Write once, run on JVM, JavaScript, WasmJS, Android, iOS via Kotlin Multiplatform.
Reliability Built‑in retries, state persistence, and checkpoint‑based restoration for fault‑tolerant agents.
Token efficiency History‑compression algorithms that shrink long conversations while preserving context.
Enterprise integration Ready‑made adapters for Spring Boot, Ktor, and other JVM frameworks.
Observability OpenTelemetry exporters; out‑of‑the‑box support for W&B Weave, Langfuse, etc.
LLM flexibility Switch models on‑the‑fly; supports OpenAI, Anthropic, Google, DeepSeek, OpenRouter, Ollama, Bedrock.
Standard protocols Implements Model Context Protocol (MCP) and Agent Client Protocol (ACP) for interoperability.
RAG & memory Vector‑based embeddings, knowledge retrieval, and long‑term memory storage.
Streaming & parallelism Real‑time response streaming and concurrent tool calls.
Modular architecture Composable feature system; you can enable only what you need.
Graph workflows Declarative graph DSL to describe complex decision trees and tool‑calling sequences.
Custom tools Easy way to expose external APIs or services as “tools” the agent can invoke.
Tracing Detailed, configurable execution traces for debugging.

Quick‑start example (from the README)

fun main() = runBlocking {
    val apiKey = System.getenv("OPENAI_API_KEY")
    val agent = AIAgent(
        promptExecutor = MultiLLMPromptExecutor(OpenAILLMClient(apiKey)),
        systemPrompt = "You are a helpful assistant. Answer user questions concisely.",
        llmModel = OpenAIModels.Chat.GPT4o
    )
    val result = agent.run("Hello! How can you help me?")
    println(result)
}

The snippet shows the typical flow: create an AIAgent with a prompt executor bound to a concrete LLM client, give it a system prompt, and call run with a user message.


Getting Koog into a project

Add the artifacts from Maven Central:

// Gradle Kotlin DSL
dependencies {
    implementation("ai.koog:koog-agents:1.3.0")
    implementation("ai.koog:koog-agents-additions:1.3.0-beta")
}

Or the equivalent Groovy/Maven coordinates (see the README). The library requires JDK 17+ and Kotlin 2.3.10+.


Typical use cases

Scenario How Koog helps
Customer‑support chatbot Persistent conversation state, history compression, and easy integration with Spring Boot back‑ends.
Enterprise RAG assistant Vector‑based knowledge store, MCP‑compatible context passing, and ability to swap LLM providers without losing history.
Mobile AI assistant Kotlin‑Multiplatform lets you run the same agent code on Android and iOS, with optional WasmJS fallback for web.
Tool‑driven automation Define custom tools that call internal services; Koog’s graph workflow orchestrates tool selection and execution.
Observability‑heavy deployments OpenTelemetry + built‑in exporters feed metrics/traces to existing monitoring stacks.

Documentation & community


License

Apache 2.0 – free for commercial and non‑commercial use, with the usual patent grant.


TL;DR

Koog is a production‑grade, Kotlin‑native toolkit for building LLM‑powered agents. It offers multiplatform deployment, robust reliability features, seamless LLM switching, RAG support, and deep observability—all wrapped in a type‑safe DSL that fits naturally into existing JVM/Kotlin codebases.

Related

  • Project
  • Project
  • Project
  • Project
  • Project