Koog 1.0 idioms, gotchas, and scaffolding skills for Kotlin agents on the JVM
86
88%
Does it follow best practices?
Impact
86%
1.86xAverage score across 45 eval scenarios
Advisory
Suggest reviewing before use
Process steps in order. Do not skip ahead.
Two distinct caching concepts in Koog:
prompt-executor-cached — in-process cache of full prompt→response pairs. Skips the API entirely on cache hits. Useful for: deterministic dev/test runs, replaying conversations, avoiding cost on identical retriesIf the user wants to avoid the API call entirely → this skill. If they want lower-cost API calls with full LLM behavior → invoke Skill(skill: "enable-prompt-caching").
Proceed immediately to Step 2.
Ask the user which backend fits their need:
prompt-cache-files). Survives restart. Good for dev caching across multiple runs of the same scriptprompt-cache-redis). Good for multi-instance deployments where workers should share cacheprompt-cache-model) — partitions cache by model so swapping models doesn't poison resultsIf the user is in a single-process dev loop, default to file. For tests, default to in-memory. For multi-instance prod, Redis.
Proceed immediately to Step 3.
implementation("ai.koog:prompt-executor-cached:1.0.0")
// pick one backend:
implementation("ai.koog:prompt-cache-files:1.0.0")
// or:
// implementation("ai.koog:prompt-cache-redis:1.0.0")
// or in-memory (no extra dep — bundled with prompt-executor-cached)Proceed immediately to Step 4.
The cache is a decorator on the prompt executor — wrap the underlying provider executor before passing to AIAgent(...):
import ai.koog.prompt.executor.cached.CachedPromptExecutor
import ai.koog.prompt.executor.cached.FilePromptCache
import java.nio.file.Paths
val rawExecutor = simpleOpenAIExecutor(System.getenv("OPENAI_API_KEY"))
val cachedExecutor = CachedPromptExecutor(
delegate = rawExecutor,
cache = FilePromptCache(directory = Paths.get(".koog-cache")),
)
val agent = AIAgent(
promptExecutor = cachedExecutor,
llmModel = OpenAIModels.Chat.GPT4o,
systemPrompt = "...",
)Cache keying is content-based — same prompt + same model + same parameters hits the cache. Changing any of those produces a miss.
Proceed immediately to Step 5.
gen_ai.client.token.usage reports zero on cache hits — observability shows the cache is working but also shows lower "real" usage; account for this when reading dashboardsFinish 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