koog
JetBrains Koog AI Agent framework (Kotlin) - use for building AI agents with tool calling, LLM integration via OpenRouter/OpenAI/Anthropic/Google/DeepSeek, streaming, GOAP planning, MCP integration, and AI-powered workflows. Use when implementing AI agents, LLM calls, tool-calling patterns, or integrating LLM providers in Kotlin projects.
What this skill does
# Koog AI Agent Framework
Kotlin Multiplatform framework for AI agents. Published on Maven Central under `ai.koog` group.
**Current version: `0.7.3`**
## Dependencies
`koog-agents` is the umbrella module — it transitively includes all sub-modules (agents-core, agents-ext, all provider clients, tools, prompt DSL, etc.).
```kotlin
// build.gradle.kts — minimal setup (JVM project)
repositories { mavenCentral() }
val koogVersion = "0.7.3"
dependencies {
implementation("ai.koog:koog-agents:$koogVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1")
}
```
No need to add individual sub-modules like `prompt-executor-openrouter-client` — they come via `koog-agents`.
For Spring Boot, also add: `implementation("ai.koog:koog-ktor:$koogVersion")`
## Import Paths (verified from 0.7.3 JARs)
```
// Agent
ai.koog.agents.core.agent.AIAgent
ai.koog.agents.core.agent.config.AIAgentConfig
ai.koog.agents.core.agent.GraphAIAgent // graph-based agent
ai.koog.agents.core.agent.FunctionalAIAgent // functional agent
ai.koog.agents.planner.PlannerAIAgent // GOAP planner agent
// Tools
ai.koog.agents.core.tools.ToolRegistry
ai.koog.agents.core.tools.annotations.Tool
ai.koog.agents.core.tools.annotations.LLMDescription
ai.koog.agents.core.tools.reflect.ToolSet // interface for annotation-based tools
ai.koog.agents.core.tools.reflect.tools // extension for ToolRegistry DSL
// Strategies (predefined)
ai.koog.agents.ext.agent.chatAgentStrategy // chat agent with tool loop
ai.koog.agents.ext.agent.reActStrategy // ReAct pattern
ai.koog.agents.core.agent.singleRunStrategy // single LLM call + tools
ai.koog.agents.core.agent.ToolCalls // enum: SEQUENTIAL, PARALLEL, SINGLE_RUN_SEQUENTIAL
ai.koog.agents.ext.agent.singleRunStrategyWithHistoryCompression // with auto history compression
ai.koog.agents.ext.agent.HistoryCompressionConfig
// GOAP Planner Strategy
ai.koog.agents.planner.AIAgentPlannerStrategy
ai.koog.agents.planner.AIAgentPlannerStrategyBuilder
ai.koog.agents.planner.GOAPStrategyBuilder
ai.koog.agents.planner.goap.GoapAgentState
// Strategy DSL (custom strategies)
ai.koog.agents.core.dsl.builder.strategy
ai.koog.agents.core.dsl.builder.forwardTo
ai.koog.agents.core.dsl.extension.nodeLLMRequest
ai.koog.agents.core.dsl.extension.nodeLLMRequestMultiple // multiple responses
ai.koog.agents.core.dsl.extension.nodeLLMRequestStreaming // streaming
ai.koog.agents.core.dsl.extension.nodeExecuteTool
ai.koog.agents.core.dsl.extension.nodeExecuteMultipleTools // parallel tool execution
ai.koog.agents.core.dsl.extension.nodeLLMSendToolResult
ai.koog.agents.core.dsl.extension.nodeLLMSendMultipleToolResults
ai.koog.agents.core.dsl.extension.nodeSetStructuredOutput
ai.koog.agents.core.dsl.extension.nodeLLMCompressHistory
ai.koog.agents.core.dsl.extension.onAssistantMessage
ai.koog.agents.core.dsl.extension.onMultipleAssistantMessages
ai.koog.agents.core.dsl.extension.onToolCall
ai.koog.agents.core.dsl.extension.onMultipleToolCalls
ai.koog.agents.core.dsl.extension.HistoryCompressionStrategy // WholeHistory, FromLastNMessages, Chunked, etc.
// Prompt
ai.koog.prompt.dsl.Prompt
ai.koog.prompt.dsl.prompt
// Executor
ai.koog.prompt.executor.llms.SingleLLMPromptExecutor
// Providers — see references/providers.md for full list
ai.koog.prompt.executor.clients.openrouter.OpenRouterLLMClient
ai.koog.prompt.executor.clients.openrouter.OpenRouterModels
ai.koog.prompt.executor.clients.openrouter.OpenRouterParams
ai.koog.prompt.executor.clients.openai.OpenAILLMClient
ai.koog.prompt.executor.clients.openai.OpenAIModels
ai.koog.prompt.executor.llms.all.simpleOpenAIExecutor
// Structured Output — see references/structured-output.md for full reference
ai.koog.prompt.structure.StructuredRequest // sealed: Manual, Native
ai.koog.prompt.structure.StructuredRequestConfig // replaces old StructuredOutputConfig
ai.koog.prompt.structure.StructuredResponse
ai.koog.prompt.structure.Structure // base interface (was StructuredData)
ai.koog.prompt.structure.json.JsonStructure // was JsonStructuredData
ai.koog.prompt.executor.model.StructureFixingParser // MOVED from prompt.structure package
ai.koog.agents.ext.agent.structuredOutputWithToolsStrategy
// Streaming
ai.koog.prompt.streaming.StreamFrame // sealed: TextDelta, TextComplete, ReasoningDelta, ReasoningComplete, ToolCallDelta, ToolCallComplete, End
// LLModel (custom model definitions)
ai.koog.prompt.llm.LLModel
ai.koog.prompt.llm.LLMProvider // subclasses: OpenRouter, OpenAI, Anthropic, Google, etc.
ai.koog.prompt.llm.LLMCapability // singletons: Completion, Temperature, Tools, Schema.JSON.Basic, etc.
// Response Processing
ai.koog.prompt.processor.ResponseProcessor // NEW: post-process LLM responses (extract tool calls from text)
// MCP Integration
ai.koog.agents.mcp.McpToolRegistryProvider // fromClient, fromTransport, fromSseUrl
ai.koog.agents.mcp.metadata.McpServerInfo
```
## AIAgent Constructor
The simplest `String→String` overload:
```kotlin
AIAgent(
promptExecutor: PromptExecutor,
llmModel: LLModel,
responseProcessor: ResponseProcessor? = null, // NEW in 0.7.x: post-process LLM responses
strategy: AIAgentGraphStrategy<String, String> = singleRunStrategy(),
toolRegistry: ToolRegistry = ToolRegistry.EMPTY,
id: String? = null,
systemPrompt: String? = null, // CHANGED: now nullable
temperature: Double? = null, // CHANGED: now nullable
numberOfChoices: Int = 1,
maxIterations: Int = 50,
installFeatures: FeatureContext.() -> Unit = {}
): AIAgent<String, String>
```
AIAgentConfig-based overload:
```kotlin
AIAgent(
promptExecutor: PromptExecutor,
agentConfig: AIAgentConfig,
strategy: AIAgentGraphStrategy<Input, Output>,
toolRegistry: ToolRegistry = ToolRegistry.EMPTY,
id: String? = null,
clock: Clock = Clock.System,
installFeatures: FeatureContext.() -> Unit = {},
): AIAgent<Input, Output>
```
AIAgentConfig constructor:
```kotlin
AIAgentConfig(
prompt: Prompt,
model: LLModel,
maxAgentIterations: Int,
missingToolsConversionStrategy: MissingToolsConversionStrategy = MissingToolsConversionStrategy.Missing(ToolCallDescriber.JSON),
responseProcessor: ResponseProcessor? = null,
serializer: JSONSerializer = KotlinxSerializer(),
)
// Convenience factory:
AIAgentConfig.withSystemPrompt(
prompt = "You are a helpful assistant",
llm = OpenAIModels.Chat.GPT4o,
id = "koog-agents",
maxAgentIterations = 3
)
```
### Agent Types
| Type | Strategy | Use case |
|------|----------|----------|
| `GraphAIAgent<I, O>` | `AIAgentGraphStrategy` | Custom strategy graphs (most common) |
| `FunctionalAIAgent<I, O>` | `AIAgentFunctionalStrategy` | Simple functional agents |
| `PlannerAIAgent<I, O>` | `AIAgentPlannerStrategy` (GOAP) | Goal-oriented planning |
### Java Builder API
```java
AIAgent<String, String> agent = AIAgent.builder()
.promptExecutor(executor)
.systemPrompt("You are a helpful assistant.")
.llmModel(OpenAIModels.Chat.GPT4o)
.toolRegistry(toolRegistry)
.build();
```
## Annotation-Based Tools
```kotlin
import ai.koog.agents.core.tools.annotations.LLMDescription
import ai.koog.agents.core.tools.annotations.Tool
import ai.koog.agents.core.tools.reflect.ToolSet
@LLMDescription("Tools for file operations")
class FileTools : ToolSet {
@Tool
@LLMDescription("Read file contents")
fun readFile(
@LLMDescription("Path to file") path: String
): String {
return java.io.File(path).readText()
}
@Tool
@LLMDescription("List files in directory")
fun listFiles(
@LLMDescription("Directory path") dir: String
): String {
return java.io.File(dir).listFiles()?.joinToString("\n") { it.name } ?: "empty"
}
}
```
RegiRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.