Koog 1.0 idioms, gotchas, and scaffolding skills for Kotlin agents on the JVM
87
88%
Does it follow best practices?
Impact
87%
1.85xAverage score across 45 eval scenarios
Advisory
Suggest reviewing before use
Process steps in order. Do not skip ahead.
Three agent subtypes in 1.0:
GraphAIAgent — wires a strategy graph (default via singleRunStrategy(), custom via strategy { ... }). What AIAgent(...) returns by defaultPlannerAIAgent — LLM-based or GOAP planner picks steps at runtime (use-planner)FunctionalAIAgent — wraps a single suspending block. No graph, no planner — programmer writes the body directlyUse functional when:
Don't use functional when:
GraphAIAgentPlannerAIAgentGraphAIAgent.FeatureContextProceed immediately to Step 2.
The top-level AIAgent(...) factory has overloads for functional strategies. Pass an AIAgentFunctionalStrategy (or the inline block factory):
import ai.koog.agents.core.agent.AIAgent
import ai.koog.agents.core.agent.AIAgentFunctionalStrategy
val agent: FunctionalAIAgent<String, String> = AIAgent.functional(
promptExecutor = simpleOpenAIExecutor(System.getenv("OPENAI_API_KEY")),
llmModel = OpenAIModels.Chat.GPT4o,
systemPrompt = "You translate inputs to formal English.",
strategy = AIAgentFunctionalStrategy { input ->
// input is the agent's String input; return the String output
val response = llm.requestSingle(input)
response.content.trim()
},
)
val out: String = agent.run("yo this kinda sucks")Inside the strategy block, this is AIAgentContext — llm, storage, clock are available. You write the LLM round-trip directly; no nodeLLMRequest, no edges.
Proceed immediately to Step 3.
Some features expect GraphAIAgent.FeatureContext and don't compose with FunctionalAIAgent. Specifically:
Trace feature's node/edge categories produce no events for a functional agent — only top-level lifecycle events fireOpenTelemetry, LongTermMemory, Tokenizer, EventHandler work as usual.
If you find yourself reaching for graph-aware features inside a functional agent, that's a signal you wanted GraphAIAgent all along — swap to strategy { ... }.
Proceed immediately to Step 4.
Functional agents are the cheapest entry point — they avoid the DSL learning curve and read like normal Kotlin. Use them for:
When the body starts to grow conditional branches, retries, or tool loops, promote to GraphAIAgent with a strategy { ... }. Don't try to push functional further than it goes — the topology you'd hand-roll inside a single suspending block becomes the graph DSL by another name, and you lose the inspectability the DSL gives.
Finish here.
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10
scenario-11
scenario-12
scenario-13
scenario-14
scenario-15
scenario-16
scenario-17
scenario-18
scenario-19
scenario-20
scenario-21
scenario-22
scenario-23
scenario-24
scenario-25
scenario-26
scenario-27
scenario-28
scenario-29
scenario-30
scenario-31
scenario-32
scenario-33
scenario-34
scenario-35
scenario-36
scenario-37
scenario-38
scenario-39
scenario-40
scenario-41
scenario-42
scenario-43
scenario-44
scenario-45
skills
add-observability
add-persistence
add-rag
add-structured-output
add-token-budgeting
add-tool
cache-llm-calls
define-prompt
domain-model-subtask-pipeline
references
enable-prompt-caching
handle-agent-events
manage-state
migrate-from-0-x
model-planner-subtasks
persist-chat-history
query-sql-from-agent
scaffold-agent
snapshot-and-restore
test-koog-agents
trace-agent-internals
use-attachments
use-functional-agent
use-llm-node-variants
use-planner
wire-a2a
wire-acp-server
wire-ktor-server
wire-mcp-server
wire-spring-boot