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
Process steps in order. Do not skip ahead.
FunctionalAIAgent for a suspending Kotlin body with direct LLM requests.GraphAIAgent for explicit nodes, edges and subgraphs.PlannerAIAgent for runtime planning.Proceed immediately to Step 2.
Pass functionalStrategy to the top-level AIAgent factory. Supply the caller's
executor; retain responsibility for closing that executor after its agents finish.
import ai.koog.agents.core.agent.AIAgent
import ai.koog.agents.core.agent.FunctionalAIAgent
import ai.koog.agents.core.agent.functionalStrategy
import ai.koog.prompt.executor.clients.openai.OpenAIModels
import ai.koog.prompt.executor.model.PromptExecutor
import ai.koog.prompt.message.MessagePart
fun formalEnglishAgent(executor: PromptExecutor): FunctionalAIAgent<String, String> =
AIAgent<String, String>(
promptExecutor = executor,
llmModel = OpenAIModels.Chat.GPT4o,
systemPrompt = "Rewrite the input in formal English. Return only the rewrite.",
strategy = functionalStrategy {
val response = requestLLM(it)
response.parts.filterIsInstance<MessagePart.Text>()
.joinToString("\n") { part -> part.text }.trim()
},
)
suspend fun rewrite(executor: PromptExecutor, input: String): String {
val agent = formalEnglishAgent(executor)
return try {
agent.run(input)
} finally {
agent.close()
}
}The strategy receiver is AIAgentFunctionalContext. requestLLM adds the input to
the prompt and requests a response. Read text from MessagePart.Text parts.
Proceed immediately to Step 3.
FunctionalAIAgent.FeatureContext.ToolRegistry and implement a bounded loop using
getToolCalls, executeTools and sendToolResults.Proceed immediately to Step 4.
Run ./gradlew build. Exercise rewrite with a mock executor returning a known
text response; verify the trimmed rewrite and agent cleanup. Exercise any tool
loop's termination bound and registered tools separately. If compilation or a
behavior check fails, correct the factory, imports or strategy and repeat the checks.
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