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.
Prompt caching, as covered here, is the Anthropic caching feature (cache breakpoints in the messages API; cache hits billed at reduced rates). Koog 1.0 enables automatic caching when calling Anthropic models.
If the user is on OpenAI, Google, or another provider, redirect:
Skill(skill: "cache-llm-calls") — uses prompt-executor-cachedIf the user is on Anthropic, proceed to Step 2.
Koog 1.0 turned on automatic Anthropic prompt caching by default. Long system prompts and repeated tool definitions are cached without code changes.
To verify it's working, check the token-usage span attributes after a few runs:
cache_creation_input_tokens and cache_read_input_tokens in the gen_ai.client.token.usage metriccache_creation_input_tokens > 0); subsequent calls within Anthropic's TTL hit it (cache_read_input_tokens > 0)If you don't have telemetry installed, invoke Skill(skill: "add-observability") first. Without it you can't tell whether caching is helping.
If automatic caching is sufficient, finish here. Continue to Step 3 only if the user needs explicit breakpoints.
cacheControl BreakpointsUse when the prompt has a clear "stable prefix + volatile suffix" shape and automatic caching is missing the optimal split — e.g., a long static system prompt followed by short variable user inputs.
The 1.0 prompt DSL exposes cacheControl on prompt segments. Set a breakpoint at the boundary between stable and volatile content:
import ai.koog.prompt.dsl.prompt
import ai.koog.prompt.cache.CacheControl
val cachedPrompt = prompt("triage") {
system("""
You are a GitHub triage assistant.
[... long stable instructions ...]
""".trimIndent(), cacheControl = CacheControl.Ephemeral)
// Anything after this point is treated as volatile and not cached
}CacheControl.Ephemeral is the standard 5-minute Anthropic cache tier. Anthropic's caching has minimum-size requirements (typically ≥1024 tokens for Sonnet/Opus, ≥2048 for Haiku); breakpoints on shorter content are silently ignored by the API — no error, just no savings.
The deprecated user(..., cacheable = true) form from pre-1.0 was removed; the cacheControl parameter is the new explicit surface.
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