Sandbox
@JetBrains/koog

Kotlin framework for AI agents and workflows

Koog gives you a Kotlin and Java API for building AI agents with tools, memory, streaming, tracing, and workflow graphs. It is built as a multiplatform framework, so you can use the same core ideas across JVM, Android, iOS, JS, and WasmJS.

4,568 stars473 forksKotlinUpdated 10d ago
Who it's for

Builders who want to ship agent-based apps in Kotlin or Java across multiple runtimes.

What it delivers

You can build agent systems that are reusable, observable, and easier to run across different platforms.

What it does

Multiplatform agent runtime

Runs across JVM, JS, WasmJS, Android, and iOS targets with Kotlin Multiplatform.

Fault-tolerant execution

Includes retries and agent state persistence so execution can resume from saved points.

History compression

Compresses long conversation history to save tokens while keeping context.

LLM provider switching

Lets you switch between providers like OpenAI, Anthropic, Google, OpenRouter, Ollama, and Bedrock.

MCP integration

Uses Model Context Protocol tools inside agents.

ACP integration

Supports Agent Client Protocol so agents can work with standard client apps.

Memory and retrieval

Adds vector embeddings and RAG for knowledge stored across conversations.

Streaming and parallel tool calls

Processes responses in real time and handles multiple tool calls at once.

How to get it

  1. 1Add dependencies to the build.gradle.kts file
    dependencies {
        implementation("ai.koog:koog-agents:1.2.0")
        implementation("ai.koog:koog-agents-additions:1.2.0-beta")
    }
  2. 2Add dependencies to the build.gradle file
    dependencies {
        implementation 'ai.koog:koog-agents:1.2.0'
        implementation 'ai.koog:koog-agents-additions:1.2.0-beta'
    }

README

Koog

Kotlin Stable Maven Central JetBrains incubator project Kotlin CI status GitHub license

Build status:

Checks Heavy Tests Ollama Tests

Useful links:

Overview

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:

  • 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.
  • Flexible graph workflows: Design complex agent behaviors using intuitive graph-based workflows.
  • Custom tool creation: Enhance your agents with tools that access external systems and APIs.
  • Comprehensive tracing: Debug and monitor agent execution with detailed, configurable tracing.

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:

fun main() = 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("Hello! How can you help me?")
    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)

Gradle (Kotlin DSL)

  1. Add dependencies to the build.gradle.kts file:

    dependencies {
        implementation("ai.koog:koog-agents:1.2.0")
        implementation("ai.koog:koog-agents-additions:1.2.0-beta")
    }
    
  2. Make sure that you have mavenCentral() in the list of repositories.

Gradle (Groovy)

  1. Add dependencies to the build.gradle file:

    dependencies {
        implementation 'ai.koog:koog-agents:1.2.0'
        implementation 'ai.koog:koog-agents-additions:1.2.0-beta'
    }
    
  2. Make sure that you have mavenCentral() in the list of repositories.

Maven

  1. Add dependencies to the pom.xml file:

    <dependency>
        <groupId>ai.koog</groupId>
        <artifactId>koog-agents-jvm</artifactId>
        <version>1.2.0</version>
    </dependency>
    <dependency>
        <groupId>ai.koog</groupId>
        <artifactId>koog-agents-additions-jvm</artifactId>
        <version>1.2.0-beta</version>
    </dependency>
    
  2. Make sure that you have mavenCentral in the list of repositories.

Versioning

Koog framework is stable and follows semantic versioning. See VERSIONING.md for details.

Contributing

Read the Contributing Guidelines.

Code of Conduct

This project and the corresponding community are governed by the JetBrains Open Source and Community Code of Conduct. Please make sure you read it.

License

Koog is licensed under the Apache 2.0 License.

Support

Please feel free to ask any questions in our official Slack channel and to use Koog official YouTrack project for filing feature requests and bug reports.

Files in the repo

Repository payload45 top-level entries
  • .claude
  • .devcontainer
  • .github
  • a2a
  • agents
  • convention-plugin-ai
  • docs
  • embeddings
  • examples
  • gradle
  • http-client
  • inspections
  • integration-tests
  • koog-agents
  • koog-agents-additions
  • koog-bedrock-agentcore-runtime
  • koog-ktor
  • koog-spring-ai
  • koog-spring-ai-v2
  • koog-spring-boot-starter
  • license
  • prompt
  • rag
  • serialization
  • skills
  • test-utils
  • utils
  • .editorconfig
  • .gitignore
  • AGENTS.md
  • build.gradle.kts
  • CHANGELOG.md
  • CLAUDE.md
  • CODEX.md
  • CONTRIBUTING.md
  • GEMINI.md
  • GPT.md
  • gradle.properties
  • gradlew
  • gradlew.bat
  • LICENSE.txt
  • README.md
  • settings.gradle.kts
  • TESTING.md
  • VERSIONING.md

Discussion (0)

Ask about usage, or say what you built with it

Sign in to join the discussion.

No comments yet. Be the first to say what this is good for.

More frameworks & sdks

HKUDS/nanobotFrameworks & SDKs

Ultra-lightweight, open-source, self-hosted personal AI agent framework in Python with WebUI, tools, memory, MCP, multi-agent workflows, automation, and chat apps

48k
microsoft/
SkillOpt
microsoft/SkillOptFrameworks & SDKs

SkillOpt is a text-space optimizer that trains reusable natural-language skills for frozen LLM agents through trajectory-driven edits, validation-gated updates, and deployable best_skill.md artifacts.

17k
omnigent-ai/omnigentFrameworks & SDKs

Omnigent is an open-source AI agent framework and meta-harness: orchestrate Claude Code, Codex, Cursor, Pi, and custom agents — swap harnesses without rewriting, enforce policies and sandboxing, and collaborate in real time from any device.

9.8k
kyegomez/
OpenMythos
kyegomez/OpenMythosFrameworks & SDKs

A theoretical reconstruction of the Claude Mythos architecture, built from first principles using the available research literature.

15k
D4Vinci/ScraplingFrameworks & SDKs

🕷️ An adaptive Web Scraping framework that handles everything from a single request to a full-scale crawl!

80k