Koog 1.3 idioms, gotchas, and scaffolding skills for Kotlin agents on the JVM
72
91%
Does it follow best practices?
Run evals on this skill
Adds up to 20 points to the overall score
Low
Low-risk findings worth noting
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.
Available actions:
systemPrompt (default — when a one-paragraph instruction is enough)prompt { ... } builder with few-shot examples and structured turnssystemPromptIf the user just wants to set an instruction string, the factory's systemPrompt parameter is the right surface. No DSL needed:
import ai.koog.agents.core.agent.AIAgent
import ai.koog.prompt.executor.clients.openai.OpenAIModels
import ai.koog.prompt.executor.model.PromptExecutor
fun triageAgent(executor: PromptExecutor) = AIAgent(
promptExecutor = executor,
llmModel = OpenAIModels.Chat.GPT4o,
systemPrompt = """
You are a GitHub triage assistant. Classify issues, suggest labels,
and link related issues by number when relevant.
""".trimIndent(),
)If the user is reaching for more structure than a single string supports, escalate to Step 2.
Finish here.
prompt { ... } BuilderUse the DSL when you need system + assistant + user turns interleaved (few-shot examples), or when the same prompt shape is reused across multiple agents.
import ai.koog.agents.core.agent.AIAgent
import ai.koog.agents.core.agent.config.AIAgentConfig
import ai.koog.prompt.dsl.prompt
import ai.koog.prompt.executor.clients.openai.OpenAIModels
import ai.koog.prompt.executor.model.PromptExecutor
val triagePrompt = prompt("issue-triage") {
system("You are a GitHub triage assistant. Classify issues as bug, feature, or question.")
// Few-shot example 1
user("App crashes on Windows when I open the Settings dialog.")
assistant("""{"classification": "bug", "confidence": 0.95}""")
// Few-shot example 2
user("Could we add dark mode to the export view?")
assistant("""{"classification": "feature", "confidence": 0.9}""")
// The actual turn is appended at runtime by the agent
}
fun fewShotAgent(executor: PromptExecutor) = AIAgent(
promptExecutor = executor,
agentConfig = AIAgentConfig(
prompt = triagePrompt,
model = OpenAIModels.Chat.GPT4o,
maxAgentIterations = 50,
),
)The Prompt class lives in ai.koog.prompt.Prompt as of 1.0 (moved from ai.koog.prompt.dsl.Prompt, #2022); the prompt { ... } builder DSL stays in ai.koog.prompt.dsl.
Pass a built Prompt through AIAgentConfig.prompt, as shown above.
For per-node context, use Step 3.
Finish here.
Add runtime data in the graph node where it becomes available. Pass the required data explicitly; append context before the next LLM request.
import ai.koog.agents.core.agent.context.AIAgentGraphContextBase
// Call addAccountContext(this, accountContext) inside the boundary node.
suspend fun addAccountContext(context: AIAgentGraphContextBase, accountContext: String) {
context.llm.writeSession {
appendPrompt {
system("Account context: $accountContext")
}
}
}Call the helper once at the intended boundary. Use user(...) for untrusted
user-provided text instead of elevating it to a system instruction.
For cross-session retrieval, invoke Skill(skill: "manage-state") Step 3.
Its SystemPromptAugmenter / UserPromptAugmenter types belong to
ai.koog.agents.longtermmemory.retrieval.augmentation and are configured inside
LongTermMemory's retrieval { promptAugmenter = ... } block.
Write the selected prompt and agent configuration to the user's source file.
Run ./gradlew build; verify that the model receives the intended instruction,
few-shot turns or runtime context in the chosen agent/node.
Finish here.
.tessl-plugin
skills
add-observability
add-persistence
references
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
references
test-koog-agents
trace-agent-internals
use-agent-skills
references
use-attachments
use-cli-agents
use-functional-agent
use-llm-node-variants
use-planner
wire-a2a
wire-acp-server
wire-ktor-server
wire-mcp-server
wire-spring-boot