This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This repository contains the Koan Agents framework, a Kotlin multiplatform library for building AI agents. The framework enables creating intelligent agents that interact with tools, handle complex workflows, and maintain context across conversations.
# Build the project
./gradlew assemble
# Compile test classes
./gradlew jvmTestClasses jsTestClasses
# Run all JVM tests
./gradlew jvmTest
# Run all JS tests
./gradlew jsTest
# Run a specific test class
./gradlew jvmTest --tests "fully.qualified.TestClassName"
# Example:
./gradlew jvmTest --tests "ai.koog.agents.test.SimpleAgentIntegrationTest"
# Run a specific test method
./gradlew jvmTest --tests "fully.qualified.TestClassName.testMethodName"
# Example:
./gradlew jvmTest --tests "ai.koog.agents.test.SimpleAgentIntegrationTest.integration_simpleSingleRunAgentShouldNotCallToolsByDefault"-
agents-core: Core abstractions and interfaces
- AIAgent, AIAgentStrategy, event handling system, AIAgent, execution strategies, session management
-
agents-tools: Tool infrastructure
- Tool, ToolRegistry, ToolDescriptor
-
agents-features: Extensible agent capabilities
- Memory, tracing, and other features
-
prompt: LLM interaction layer
- LLM executors, prompt construction, structured data processing
- Agents: State-machine graphs with nodes that process inputs and produce outputs
- Tools: Encapsulated actions with standardized interfaces
- Strategies: Define agent behavior and execution flow
- Features: Installable extensions that enhance agent capabilities
- Event Handling: System for intercepting and processing agent lifecycle events
- Define tools that agents can use
- Register tools in the ToolRegistry
- Configure agent with strategy
- Set up communication (if integrating with external systems)
The project has extensive testing support:
-
Mocking LLM responses:
val mockLLMApi = getMockExecutor(toolRegistry, eventHandler) { mockLLMAnswer("Hello!") onRequestContains "Hello" mockLLMToolCall(CreateTool, CreateTool.Args("solve")) onRequestEquals "Solve task" }
-
Mocking tool calls:
mockTool(PositiveToneTool) alwaysReturns "The text has a positive tone."
-
Testing agent graph structure:
testGraph { assertStagesOrder("first", "second") // ... }
For detailed testing guidelines, refer to agents/agents-test/TESTING.md.