Koog 1.0 idioms, gotchas, and scaffolding skills for Kotlin agents on the JVM
71
88%
Does it follow best practices?
Impact
—
No eval scenarios have been run
Advisory
Suggest reviewing before use
Process steps in order. Do not skip ahead.
Persistence (add-persistence) writes checkpoints automatically on a configured schedule (every node, every N steps, every successful turn). Snapshot is caller-triggered — you call snapshot() when you decide it's a useful save point.
Use snapshot when:
If the user's need is "agent should resume after a crash", invoke Skill(skill: "add-persistence"). If it's "save state at this specific point", continue.
Proceed immediately to Step 2.
implementation("ai.koog:agents-features-snapshot:1.0.0")Proceed immediately to Step 3.
import ai.koog.agents.features.snapshot.Snapshot
val agent = AIAgent(
promptExecutor = ...,
llmModel = ...,
systemPrompt = "...",
) {
install(Snapshot) {
// optional: storage backend (in-memory, disk, JDBC)
}
}Proceed immediately to Step 4.
Inside a node body (or from outside the run via the agent's API), call snapshot():
// inside a node body
val snapshotId = snapshot() // returns an identifier you store
storeSnapshotId(snapshotId)Restore by passing the snapshot ID to runFromSnapshot:
val snapshotId = loadSnapshotId()
val result = agent.runFromSnapshot(snapshotId, additionalInput = null)Snapshots are the typed-storage half of persistence — AIAgentStorage rides along automatically (values must be @Serializable, see manage-state). Non-serializable types break snapshots silently, same as checkpoints.
Forking — take a snapshot, run one branch, restore, run another:
val branchPoint = snapshot()
val resultA = agent.runFromSnapshot(branchPoint, additionalInput = "variant A input")
val resultB = agent.runFromSnapshot(branchPoint, additionalInput = "variant B input")Useful for A/B testing strategy variants without re-running the prefix.
Finish here.
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