Skip to content

Examples

The Koog framework provides examples to help you understand how to implement AI agents for different use cases. Examples are available in both Kotlin and Java. They demonstrate key features and patterns that you can adapt for your own applications.

Browse the examples below and click on the links to view the source code on GitHub.

Example Description
Attachments Learn how to use structured Markdown and attachments in prompts. Build prompts that include images and generate creative content for Instagram posts using OpenAI models.
Banking Build a comprehensive AI banking assistant with routing capabilities that can handle money transfers and transaction analysis through a sophisticated graph-based strategy. Includes domain modeling, tool creation, and agent composition patterns.
BedrockAgent Create intelligent AI agents using the Koog framework with AWS Bedrock integration. Learn how to define custom tools, set up AWS Bedrock, and build interactive agents that understand natural language commands for controlling devices.
Calculator Build a calculator agent that performs arithmetic operations using tools for addition, subtraction, multiplication, and division. Demonstrates parallel tool calls, event logging, and multiple executor support (OpenAI and Ollama).
Chess Build an intelligent chess-playing agent featuring complex domain modeling, custom tools, memory optimization techniques, and interactive choice selection. Demonstrates advanced agent strategies, game state management, and human-AI collaboration patterns.
GoogleMapsMcp Connect Koog to a Google Maps MCP server via Docker. Discover tools, geocode addresses, and fetch elevation data using AI agents with real-world geographic APIs in a Kotlin Notebook environment.
Guesser Build a number-guessing agent that implements a binary search strategy using tools to ask targeted questions. The agent efficiently narrows down the user's number through strategic questioning and demonstrates tool-based interaction patterns.
Langfuse Learn how to export Koog agent traces to Langfuse using OpenTelemetry. Set up environment variables, run agents, and inspect spans and traces in your Langfuse instance for comprehensive observability.
MCP Integration examples for the Model Context Protocol, featuring GoogleMapsMcpClient for geographic data and PlaywrightMcpClient for browser automation.
Memory A customer support agent that demonstrates memory system usage. The agent tracks user conversation preferences, device diagnostics, and organization-specific information using encrypted local storage and proper memory organization with subjects and scopes.
OpenTelemetry Add OpenTelemetry-based tracing to Koog AI agents. Learn to emit spans to console for debugging and export traces to OpenTelemetry Collector for viewing in Jaeger. Includes Docker setup and troubleshooting guide.
Planner A task planning system that builds execution trees with parallel and sequential execution nodes, dynamically constructing execution plans for complex workflows.
PlaywrightMcp Drive browsers with Playwright MCP and Koog. Launch a Playwright MCP server, connect via SSE, and let AI agents automate web tasks like navigation, cookie acceptance, and UI interaction through natural language commands.
SimpleAPI Examples demonstrating chat agents and basic agents with simple API patterns for getting started with Koog.
StructuredData Demonstrates JSON-based structured data output with complex nested classes, polymorphism, and weather forecast examples showing how to work with typed data in agent responses.
SubgraphWithTask Project generation tools showcasing file and directory operations, including creation, deletion, and command execution using subgraph strategies.
Tone A text tone analysis agent that uses specialized tools to identify positive, negative, or neutral tones in input text, demonstrating sentiment analysis capabilities.
UnityMcp Drive Unity game development with AI agents using Unity MCP server integration. Connect to Unity via stdio, discover available tools, and let agents modify scenes, place objects, and execute game development tasks through natural language commands.
VaccumAgent Implementation of a basic reflex agent using the Koog framework. Covers environment modeling, tool creation, and agent behavior for automated cleaning tasks in a simple two-cell world.
Weave Learn how to trace Koog agents to W&B Weave using OpenTelemetry (OTLP). Set up environment variables, run agents, and view rich traces in the Weave UI for comprehensive monitoring and debugging.
A2A Demonstrates agent-to-agent (A2A) communication using Koog framework. Shows how to set up bidirectional communication between AI agents, enable collaborative problem-solving, and manage multi-agent workflows with proper message routing and coordination.
Example Description
Calculator Build a graph-based calculator agent. Demonstrates tools defined using ToolSet, a multi-node graph strategy with typed edges, conditional routing, automatic history compression, event handling, and multiple executor support (OpenAI and Ollama).
FunctionalAgentChat Build an interactive chat agent using a functional strategy. Runs a continuous conversation loop powered by the Llama 3.2 model, accepting user input until /bye is entered.
ChatMemoryJdbc Persist conversation history across sessions using the ChatMemory feature backed by a JDBC PostgreSQL provider. Demonstrates creation of JDBC-backed chat history provider with 24h TTL, schema migration, and building the agent with chat memory. Requires PostgreSQL running locally or via Docker.
FunctionalStrategy Implement a multi-step functional strategy with typed subtasks, per-step tool scoping, and an iterative verification and fixing loop to produce validated solutions.
GoapStrategy Build a planner-based agent using GOAP (Goal-Oriented Action Planning). Define typed belief states, action preconditions, and goal conditions to guide iterative problem-solving and self-correction.
GraphStrategy Build a graph-based problem-solving agent with typed subgraphs connected by conditional edges. Implements a problem-solving pipeline using LLM-as-a-judge to validate solutions.
CustomSubgraph Build a multi-subgraph agent strategy. Implements 3 subgraphs connected sequentially that handle research with a web search tool, outline planning, and write a final article summary.
OpenTelemetry Add OpenTelemetry-based tracing to a Koog AI agent. Configures a console logging exporter for local debugging and an OTLP/gRPC exporter for viewing spans in Jaeger. Includes a Docker setup.
Langfuse Export Koog agent traces to Langfuse via OpenTelemetry. Demonstrates configuring custom attributes such as session ID and trace tags for enriched observability.
Weave Trace Koog agents to W&B Weave using OpenTelemetry (OTLP). Set up environment variables, run agents, and view rich traces in the Weave UI.
PersistenceJdbc Build an agent with the Persistence feature backed by a JDBC PostgreSQL provider. The Persistence feature automatically creates checkpoints after each node execution, allowing the agent to resume from where it left off across restarts. Requires PostgreSQL running locally or via Docker.