This repository contains examples and utilities for working with the Koog AI agent framework.
Koog Playground demonstrates various capabilities of the Koog framework for building AI agents, including:
- AI Agents: Implementations of autonomous agents.
- Strategy Patterns: Custom graphs, history compression, and structured data processing.
- MCP (Model Context Protocol): Integrations with Google Maps and Playwright.
- Tool Sets: Extending agent capabilities with weather tools and diagnostics.
- Observability: OpenTelemetry and Langfuse tracing integration.
- JDK 25 or higher (configured in
libs.versions.toml) - Gradle (wrapper included)
- Docker (optional, for Langfuse tracing)
.
βββ build.gradle.kts # Project build configuration
βββ gradle/libs.versions.toml # Dependency and version management
βββ src
β βββ main/kotlin
β β βββ Main.kt # Main entry point with interactive menu
β β βββ QuickstartExample.kt
β β βββ me/bossm0n5t3r
β β βββ agent/ # Agent implementations
β β βββ api/ # LLM API examples
β β βββ di/ # Koin dependency injection
β β βββ mcp/ # Model Context Protocol tools
β β βββ opentelemetry/# Tracing and observability
β β βββ strategies/ # AI interaction strategies
β β βββ tools/ # Agent tool sets
β β βββ utils/ # General utilities
β βββ test/kotlin # Unit tests
βββ LICENSE
You can use the provided setup script to create your .env file:
./setup-env.shThe script will:
- Check if environment variables (like
OPENAI_API_KEY) are already set in your terminal and suggest them as default values. - Allow you to use shell variables by entering them with a
$prefix (e.g.,$MY_KEY_VAR). - Use default values from
.env.exampleif no environment variable or user input is provided.
Alternatively, you can manually create a .env file in the project root by copying from .env.example:
cp .env.example .envThen edit .env and fill in your API keys:
OPENAI_API_KEY=your_openai_api_key_here
GOOGLE_AI_STUDIO_API_KEY=your_google_ai_studio_api_key_here
GOOGLE_MAPS_API_KEY=your_google_maps_api_key_here
The project uses a simple custom .env loader (DotenvLoader) to load these variables.
./gradlew buildThe project provides an interactive menu to explore different examples:
./gradlew runAlternatively, you can run specific examples if they have a main function (e.g., QuickstartExample.kt).
When running the application, you can choose from:
- PromptApi: High-level prompt API usage.
- SingleApi: Direct LLM API calls.
- AIAgent: Core agent functionality.
- AgentWithWeatherToolSet: Agent using external tools.
- StructuredDataProcessing: Extracting structured info using AI.
- Google Maps: MCP integration for location data.
- Playwright: MCP integration for browser automation.
To try the Langfuse tracing example:
- Navigate to
src/main/kotlin/me/bossm0n5t3r/opentelemetry/langfuse/. - Start Langfuse using Docker:
docker-compose up -d
- Configure the
.envfile in that directory with your Langfuse credentials. - Run
AgentWithLangfuseTracing.kt.
./setup-env.sh: Create or update the.envfile interactively../gradlew run: Start the interactive menu../gradlew test: Run all tests../gradlew ktlintCheck: Check code style../gradlew ktlintFormat: Auto-format code.
Tests are written using JUnit 5 and MockK.
./gradlew testThis project is licensed under the MIT License - see the LICENSE file for details.