# Koog

> JetBrains' framework for building AI agents in idiomatic Kotlin and Java, from backend services to Android and iOS

- Category: Agents & Automation / Agent Frameworks & Builders
- Language: Kotlin
- Licence: Apache-2.0
- Repository: https://github.com/JetBrains/koog
- Website: https://docs.koog.ai
- Canonical page: https://ai-tldr.dev/tools/koog/
- Updated: 2026-09-24

## In short

Koog is an open-source framework from JetBrains for building and running AI agents entirely in Kotlin or Java. It sits in the Agent Frameworks & Builders category of the Agents & Automation tools and is open-source, written in Kotlin and licensed Apache-2.0. To get started: add the dependency.

## Overview

Koog is an open-source framework from JetBrains for building and running AI agents entirely in Kotlin or Java. Instead of wrapping a Python stack, it gives JVM teams a type-safe Kotlin DSL and fluent Java builder APIs for agents that call tools, run multi-step workflows and talk to users. JetBrains open-sourced it in May 2025, shipped the first stable 1.0 release on May 21, 2026, and publishes it on Maven Central under the Apache 2.0 license.

Every Koog agent runs a strategy: a directed graph of nodes such as "call the LLM", "execute a tool" and "send the tool result back". The simplest agents use a predefined strategy (a basic tool-calling loop, or ReAct, which alternates a reasoning step with an action step), while graph-based agents define their own nodes, edges, subgraphs and parallel branches. Koog also offers functional agents, where the logic is a plain lambda, and planner agents (beta) that build and execute a plan step by step.

Around that core sit the features long-running production agents need: built-in retries, agent persistence that restores state from a checkpoint, history compression to keep long conversations within the context window, switching to a different LLM mid-conversation without losing history, streaming, structured output, and RAG with embeddings. With Kotlin Multiplatform the same agent code targets the JVM, JS, WasmJS, Android and iOS, and integrations cover Spring Boot, Spring AI, Ktor, Amazon Bedrock AgentCore, the Model Context Protocol, A2A and the Agent Client Protocol.

## What it does

- Basic, functional, graph-based and planner (beta) agents, written in an idiomatic Kotlin DSL or with fluent Java builders
- Strategy graphs with predefined strategies such as ReAct, custom nodes, subgraphs, parallel node execution and typed data transfer between nodes
- Tools as annotated functions (@Tool and @LLMDescription), class-based tools or built-in tools, plus MCP (beta), A2A (beta) and Agent Client Protocol integration
- Reliability features: retries, agent persistence with checkpoints, history compression and switching LLM providers without losing the conversation
- Clients for OpenAI, Anthropic, Google, DeepSeek, OpenRouter, Amazon Bedrock, Mistral and local Ollama models, with streaming and structured output
- Tracing and OpenTelemetry exporters for Langfuse, W&B Weave and Datadog, and starters for Spring Boot, Spring AI and Ktor

## Getting started

Koog needs JDK 17 or newer on the JVM and Kotlin 2.3.10 or newer set explicitly in existing projects. The steps follow the project's README and the Quickstart in the Koog docs.

1. Add the dependency

   Koog is on Maven Central. Add the core agents artifact (and, optionally, the beta additions module) to your Gradle build and make sure mavenCentral() is in your repositories. Maven users depend on koog-agents-jvm instead.

```kotlin
dependencies {
    implementation("ai.koog:koog-agents:1.3.0")
    implementation("ai.koog:koog-agents-additions:1.3.0-beta")
}
```

2. Set a provider API key

   Koog needs an API key from a supported provider or a local model running in Ollama. Keep the key in an environment variable rather than in source code.

```bash
export OPENAI_API_KEY=your-api-key
```

3. Create and run your first agent

   An AIAgent combines a prompt executor (the LLM client), a model and an optional system prompt. Calling run sends the input and returns the agent's answer.

```kotlin
fun main() = runBlocking {
    val apiKey = System.getenv("OPENAI_API_KEY")
        ?: error("The API key is not set.")

    val agent = AIAgent(
        promptExecutor = MultiLLMPromptExecutor(OpenAILLMClient(apiKey)),
        llmModel = OpenAIModels.Chat.GPT4o
    )

    val result = agent.run("Hello! How can you help me?")
    println(result)
}
```

4. Give the agent a tool

   Annotate functions in a class that implements ToolSet, describe them for the model with @LLMDescription, and register the set in the agent's ToolRegistry. The agent can then decide to call the tool while it works.

```kotlin
@LLMDescription("Tools for getting weather information")
class MyFirstToolSet : ToolSet {
    @Tool
    @LLMDescription("Get the current weather for a location")
    fun getWeather(
        @LLMDescription("The city and state/country")
        location: String
    ): String {
        return "The weather in $location is sunny and 72°F"
    }
}

val agent = AIAgent(
    promptExecutor = simpleOpenAIExecutor(apiKey),
    systemPrompt = "Provide weather information for a given location.",
    llmModel = OpenAIModels.Chat.GPT4o,
    toolRegistry = ToolRegistry { tools(MyFirstToolSet()) }
)
agent.run("What's the weather like in New York?")
```

## When to use it

- Adding AI agents to an existing Spring Boot or Ktor backend without introducing a Python service
- Shipping the same agent logic to Android, iOS and web clients through Kotlin Multiplatform
- Building long-running, multi-step agents that must survive failures, resume from checkpoints and stay within the context window
- Tracing and debugging agent runs node by node in Langfuse, W&B Weave or Datadog

## Version history

- 2026-09-24 1.3.0: Adds ready-made model definitions with capabilities, context windows and pricing for new Anthropic, OpenAI, Google, Bedrock, DashScope, DeepSeek, Mistral, Ollama and OpenRouter models, and fixes Google prompt-cache token counts and empty assistant content in Langfuse traces.
- 2026-05-21 1.0.0: First stable release: modules split into stable and beta streams, deprecated APIs removed, graph DSL node names finalized, a redesigned Java interop layer, OpenTelemetry on Kotlin Multiplatform and Anthropic prompt caching.
