Koog 1.0 idioms, gotchas, and scaffolding skills for Kotlin agents on the JVM
88
88%
Does it follow best practices?
Impact
88%
1.95xAverage score across 43 eval scenarios
Passed
No known issues
This skill is an action router — pick the step that matches the user's intent and execute only that step. Do not run other steps; do not parallelize.
Chaining exception (exhaustive — overrides "Do not run other steps" only as listed):
Skill(skill: "author-strategy")) and finishes, or chains to Step 2 / Step 3 to wire the picked planner variantAvailable actions:
Skill(skill: "author-strategy") and finish. If yes, pick LLM-based or GOAP and chain into the relevant Step (2 or 3)Planners.llmBased or Planners.llmBasedWithCritic)Planners.goap)The graph DSL (strategy { ... }) is the right default. A planner is the right choice when any of these are true:
If the user's description matches "I know the topology, the LLM just picks tools within nodes", redirect:
Skill(skill: "author-strategy") and run it end-to-end through its Step 8author-strategy's Step 8Only if you did NOT redirect above (the planner genuinely fits), pick the variant from the user's description without blocking on a clarifying question:
data class state and precondition/effect pairsProceed to Step 2 for LLM-based, Step 3 for GOAP. This handoff applies only when the planner fits; the redirect branch above already finished.
Add the planner module to build.gradle.kts:
implementation("ai.koog:agents-planner:1.0.0")Construct the planner strategy and wire into AIAgent(...):
import ai.koog.agents.planner.Planners
import ai.koog.agents.core.agent.AIAgent
val strategy = Planners.llmBased("myStrategy")
// or with a critic loop for output quality:
// val strategy = Planners.llmBasedWithCritic("myStrategy")
val agent = AIAgent(
promptExecutor = ...,
llmModel = ...,
toolRegistry = ...,
systemPrompt = "...",
strategy = strategy,
maxIterations = 400, // planners chain many LLM steps — default 50 is far too low
)The critic variant adds an inner verify loop where a second LLM call grades each planner step before it's accepted. Use when output quality matters more than throughput; expect roughly 2× the LLM cost.
Planners.llmBased(name) is the new constructor — the old AIAgentPlannerStrategy.builder() is gone in 1.0 (#1997).
Finish here.
GOAP needs a typed, serializable state class and a set of actions defined as (precondition, effect) pairs. If the state cannot be expressed as a data class with a finite set of fields, GOAP is the wrong tool — use Step 2.
Add the planner module:
implementation("ai.koog:agents-planner:1.0.0")Define the state and the planner:
import ai.koog.agents.planner.Planners
import kotlinx.serialization.Serializable
@Serializable
data class MyState(
val hasItem: Boolean = false,
val location: String = "start",
)
val strategy = Planners.goap("myStrategy", ::MyState) {
action(
name = "pickup",
precondition = { s -> !s.hasItem && s.location == "warehouse" },
belief = { s -> s.copy(hasItem = true) }
) { _, s ->
// actual side-effect during execution
s.copy(hasItem = true)
}
action(
name = "move_to_warehouse",
precondition = { s -> s.location != "warehouse" },
belief = { s -> s.copy(location = "warehouse") }
) { _, s -> s.copy(location = "warehouse") }
goal("haveItem", condition = { s -> s.hasItem })
}belief is the planner's predicted effect (used during planning); the action body is the actual effect at execution time. They usually match but can diverge — e.g., the actual effect may also update non-state-tracked fields.
Wire into the agent:
val agent = AIAgent(
promptExecutor = ...,
llmModel = ...,
toolRegistry = ...,
systemPrompt = "...",
strategy = strategy,
maxIterations = 100,
)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
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