CtrlK
BlogDocsLog inGet started
Tessl Logo
PluginPublic

jbaruch/koog

Koog 1.3 idioms, gotchas, and scaffolding skills for Kotlin agents on the JVM

72

Quality

91%

Does it follow best practices?

Run evals on this skill

Adds up to 20 points to the overall score

View guide
SecuritybySnyk

Low

Low-risk findings worth noting

Overview
Quality
Evals
Security
Files

durable-agents.mdskills/add-persistence/references/

Durable checkpoint agents

These Koog 1.3 factories accept an existing graph strategy. Preserve the caller's planner strategy when adapting the install block to a planner agent. Custom planners pass non-null state and plan type tokens to AIAgentPlanner; their state and plan types must support serialization. SimpleLLMPlanner supplies both tokens.

PostgreSQL

Add ai.koog:agents-features-persistence-jdbc:1.3.0 and a PostgreSQL JDBC driver. Configure the required environment settings documented in the parent skill.

import ai.koog.agents.core.agent.AIAgent
import ai.koog.agents.core.agent.entity.AIAgentGraphStrategy
import ai.koog.agents.features.persistence.jdbc.PostgresJdbcPersistenceStorageProvider
import ai.koog.agents.snapshot.feature.Persistence
import ai.koog.prompt.executor.clients.openai.OpenAIModels
import ai.koog.prompt.executor.model.PromptExecutor
import org.postgresql.ds.PGSimpleDataSource

suspend fun jdbcCheckpointAgent(
    executor: PromptExecutor,
    graph: AIAgentGraphStrategy<String, String>,
): AIAgent<String, String> {
    val dataSource =
        PGSimpleDataSource().apply {
            setURL(
                requireNotNull(System.getenv("CHECKPOINT_JDBC_URL")?.takeIf { it.isNotBlank() }) {
                    "Set CHECKPOINT_JDBC_URL to the database JDBC URL; see .env.example"
                },
            )
            user =
                requireNotNull(System.getenv("CHECKPOINT_DB_USER")?.takeIf { it.isNotBlank() }) {
                    "Set CHECKPOINT_DB_USER to a provisioned database role; see .env.example"
                }
            password =
                requireNotNull(System.getenv("CHECKPOINT_DB_PASSWORD")?.takeIf { it.isNotBlank() }) {
                    "Set CHECKPOINT_DB_PASSWORD from the database credential store; see .env.example"
                }
        }
    val provider = PostgresJdbcPersistenceStorageProvider(dataSource)
    provider.migrate()
    return AIAgent(
        promptExecutor = executor,
        llmModel = OpenAIModels.Chat.GPT4o,
        strategy = graph,
    ) {
        install(Persistence) {
            storage = provider
            enableAutomaticPersistence = true
        }
    }
}

Local files

Add ai.koog:agents-features-snapshot:1.3.0 and choose a persistent directory.

import ai.koog.agents.core.agent.AIAgent
import ai.koog.agents.core.agent.entity.AIAgentGraphStrategy
import ai.koog.agents.snapshot.feature.Persistence
import ai.koog.agents.snapshot.providers.file.JVMFilePersistenceStorageProvider
import ai.koog.prompt.executor.clients.openai.OpenAIModels
import ai.koog.prompt.executor.model.PromptExecutor
import java.nio.file.Path

fun fileCheckpointAgent(
    executor: PromptExecutor,
    graph: AIAgentGraphStrategy<String, String>,
    directory: Path,
): AIAgent<String, String> =
    AIAgent(
        promptExecutor = executor,
        llmModel = OpenAIModels.Chat.GPT4o,
        strategy = graph,
    ) {
        install(Persistence) {
            storage = JVMFilePersistenceStorageProvider(directory)
            enableAutomaticPersistence = true
        }
    }

skills

add-persistence

README.md

tile.json