Skip to main content
Koog provides a rich set of installable features that extend agent capabilities. Features integrate seamlessly into the agent lifecycle through a pipeline architecture, allowing you to add functionality like memory, tracing, event handling, and persistence.

Available Features

Memory & State

Memory

Short-term conversation memory for storing and retrieving facts during agent execution

Long-term Memory

Persistent memory with vector search (RAG) for storing knowledge across sessions

Persistence

Save and restore complete agent state with checkpoints

Observability

Event Handlers

Hook into agent lifecycle events for custom logic

Tracing

Comprehensive execution tracing for debugging and analysis

OpenTelemetry

Industry-standard observability with OpenTelemetry integration

Optimization

History Compression

Intelligent conversation history compression to manage context limits

Installation Pattern

All features follow a consistent installation pattern:
val agent = AIAgent(
    executor = myExecutor,
    llmModel = OpenAIModels.Chat.GPT4o,
    strategy = myStrategy
) {
    install(FeatureName) {
        // Feature-specific configuration
    }
}

Feature Architecture

Features integrate with the agent through the pipeline architecture:

Feature Capabilities

Features can:
  • Intercept Events: Hook into agent lifecycle events
  • Transform Data: Modify prompts, messages, and results
  • Store State: Maintain feature-specific storage
  • Add Context: Inject information into agent execution

Multiplatform Support

All features are built on Kotlin Multiplatform and support:
  • JVM (Java 17+)
  • JavaScript (Node.js and Browser)
  • WASM (WebAssembly)
Platform-specific features (like file-based storage) may have different implementations across targets.

Combining Features

Features are designed to work together seamlessly:
val agent = AIAgent(...) {
    // Memory for storing facts
    install(AgentMemory) {
        memoryProvider = LocalFileMemoryProvider(...)
        productName = "my-ide"
    }
    
    // Events for monitoring
    install(EventHandler) {
        onToolCallStarting { ctx ->
            println("Tool: ${ctx.toolName}")
        }
    }
    
    // Tracing for debugging
    install(Tracing) {
        addMessageProcessor(TraceFeatureMessageLogWriter())
    }
    
    // Persistence for recovery
    install(AgentCheckpoint) {
        snapshotProvider(FileAgentCheckpointStorageProvider())
        continuouslyPersistent()
    }
}

Feature Lifecycle

Features participate in the complete agent lifecycle:
  1. Installation: Feature is configured and installed
  2. Agent Starting: Feature initializes for a new run
  3. Strategy Starting: Feature prepares for strategy execution
  4. Node Execution: Feature intercepts node processing
  5. LLM/Tool Calls: Feature monitors or modifies calls
  6. Strategy Complete: Feature finalizes strategy work
  7. Agent Complete: Feature cleans up and persists state

Best Practices

Begin with Memory and Event Handlers for most use cases. Add tracing and persistence as needed.
Use the right scope (Agent, Feature, Product, Organization) for memory to control visibility.
Features like tracing and persistence can impact performance. Use sampling or filtering in production.
Some features work better together. For example, Memory + LongTermMemory provides both short and long-term recall.

Next Steps

Memory

Add short-term memory to your agent

Event Handlers

Hook into lifecycle events

Tracing

Debug with execution traces

OpenTelemetry

Production-grade observability

Build docs developers (and LLMs) love