agentleFS
JetBrainsKnown publisherJetBrains/koog/AGENTS.md

koog

AGENTS.md4.6k starsChanged 7 months agoApache-2.0View on GitHub

Koog is a Kotlin multiplatform framework for building AI agents with graph-based workflows. It supports JVM and JS targets and integrates with multiple LLM providers (OpenAI, Anthropic, Google, OpenRouter, Ollama) and Model Context Protocol (MCP). The project follows a modular architecture with a clear separation of concerns: AIAgent — Main orchestrator that executes strategies in coroutine scopes, manages tools via ToolRegistry, runs features through AIAgentPipeline, and handles LLM communication via PromptExecutor. AIAgentStrategy — Graph-based execution logic that defines workflows as…

Trending

More talk lately.about the whole repository

Dec 2025: 1 mentionJan 2026: 0 mentionsFeb 2026: 2 mentionsMar 2026: 5 mentionsApr 2026: 2 mentionsMay 2026: 2 mentionsJun 2026: 0 mentionsJul 2026: 4 mentionsAug 2026: 3 mentionsSep 2026: 12 mentionsOct 2026: 5 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the JetBrains/koog repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about JetBrains/koog

The biggest 5 of 59 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 59

Talked about on GitHub, Bluesky and Hacker News (59 times).

On GitHub · 46

41 more on GitHub

On Bluesky · 12

7 more on Bluesky

On Hacker News · 1

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

23 rules. About 1 is common, 19 are distinctive, and 3 are very specific to this project.

  • ≈1

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈19

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  • could be automatic: a setting could enforce it
  1. Distinctive:

    Follow Kotlin Coding Conventions

    line 64
  2. Distinctive:

    Use four spaces for indentation (consistent across all files)

    line 65
  3. Distinctive:

    Use descriptive variable and function names

    line 67
  4. Distinctive:

    Prefer functional programming patterns where appropriate

    line 68
  5. Distinctive:

    Use type-safe builders and DSLs for configuration

    line 69
  6. Distinctive:

    Document public APIs with KDoc comments

    line 70
  7. Distinctive:

    NEVER suppress compiler warnings without a good reason

    line 71
  8. Distinctive:

    Read and follow the Quality Gates section in /TESTING.md before considering any code change complete.

    line 74
  9. Common:

    NEVER: commit API keys or secrets to the repository

    line 173
  10. Distinctive:

    Use environment variables for all sensitive configuration

    line 174
  11. Distinctive:

    Use type-safe tool arguments to prevent injection attacks

    line 188
  12. Distinctive:

    Use specific version ranges to avoid supply chain attacks

    line 194
  13. Distinctive:

    Follow the principle of the least privilege in tool implementations

    line 196
  14. Distinctive:

    Test configuration supports both JVM and JS targets

    line 221
  15. Distinctive:

    develop: All development (features and bug fixes)

    line 233
  16. Very specific:

    Use descriptive branch names: feature/agent-memory, fix/tool-registry-bug

    line 236
  17. Very specific:

    ALWAYS: run ./gradlew build before submitting PRs

    line 240
  18. Distinctive:

    Ensure all tests pass on JVM, JS, WASM targets

    line 241
  19. Distinctive:

    Follow established patterns in existing code

    line 242
  20. Distinctive:

    Add tests for new functionality

    line 243
  21. Distinctive:

    Update documentation for API changes

    line 244
  22. Very specific:

    Use conventional commit format: feat:, fix:, docs:, test:

    line 248
  23. Distinctive:

    Keep commits focused and atomic

    line 250

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Koog AI Agent Framework

Koog is a Kotlin multiplatform framework for building AI agents with graph-based workflows. It supports JVM and JS targets and integrates with multiple LLM providers (OpenAI, Anthropic, Google, OpenRouter, Ollama) and Model Context Protocol (MCP).

Project Structure

The project follows a modular architecture with a clear separation of concerns:

koog/
├── agents/
│   ├── agents-core/           # Core abstractions (AIAgent, AIAgentStrategy, AIAgentEnvironment)
│   ├── agents-tools/          # Tool infrastructure (Tool<TArgs, TResult>, ToolRegistry, AIAgentTool)
│   ├── agents-features-*/     # Feature implementations (memory, tracing, event handling)
│   ├── agents-mcp/           # Model Context Protocol integration
│   └── agents-test/          # Testing utilities and framework
├── prompt-*/                 # LLM interaction layer (executors, models, structured data)
├── embeddings-*/             # Vector embedding support
├── examples/                 # Reference implementations and usage patterns
└── build.gradle.kts          # Root build configuration

Build & Commands

Development Commands

# Full build including tests
./gradlew build

# Build without tests
./gradlew assemble

# Run all JVM tests
./gradlew jvmTest

# Run all JS tests  
./gradlew jsTest

# Test specific module
./gradlew :agents:agents-core:jvmTest

# Run specific test class
./gradlew jvmTest --tests "ai.koog.agents.test.SimpleAgentMockedTest"

# Run specific test method  
./gradlew jvmTest --tests "ai.koog.agents.test.SimpleAgentMockedTest.test AIAgent doesn't call tools by default"

# Compile test classes only (for faster iteration)
./gradlew jvmTestClasses jsTestClasses

Development Environment

  • JDK: 17+ required for JVM target
  • Build System: Gradle with version catalogs for dependency management
  • Targets: JVM, JavaScript (Kotlin Multiplatform), WASM
  • IDE: IntelliJ IDEA recommended with Kotlin plugin

Code Style

  • Follow Kotlin Coding Conventions
  • Use four spaces for indentation (consistent across all files)
  • Name test functions as testXxx (no backticks for readability)
  • Use descriptive variable and function names
  • Prefer functional programming patterns where appropriate
  • Use type-safe builders and DSLs for configuration
  • Document public APIs with KDoc comments
  • NEVER suppress compiler warnings without a good reason

Quality Gates

Read and follow the Quality Gates section in /TESTING.md before considering any code change complete.

Architecture

Core Framework Components

AIAgent — Main orchestrator that executes strategies in coroutine scopes, manages tools via ToolRegistry, runs features through AIAgentPipeline, and handles LLM communication via PromptExecutor.

AIAgentStrategy — Graph-based execution logic that defines workflows as subgraphs with start/finish nodes, manages tool selection strategy, and handles termination/error reporting.

ToolRegistry — Centralized, type-safe tool management using a builder pattern: ToolRegistry { tool(MyTool()) }. Supports registry merging with + operator.

AIAgentFeature — Extensible capabilities installed into AIAgentPipeline with configuration. Features have unique storage keys and can intercept agent lifecycle events.

Module Organization

  1. agents-core: Core abstractions (AIAgent, AIAgentStrategy, AIAgentEnvironment)
  2. agents-tools: Tool infrastructure (Tool<TArgs, TResult>, ToolRegistry, AIAgentTool)
  3. agents-features-*: Feature implementations (memory, tracing, event handling)
  4. agents-mcp: Model Context Protocol integration
  5. prompt-*: LLM interaction layer (executors, models, structured data)
  6. embeddings-*: Vector embedding support
  7. examples: Reference implementations and usage patterns

Key Architectural Patterns

  • State Machine Graphs: Agents execute as node graphs with typed edges
  • Feature Pipeline: Extensible behavior via installable features with lifecycle hooks
  • Environment Abstraction: Safe tool execution context preventing direct tool calls
  • Type Safety: Generics ensure compile-time correctness for tool arguments/results
  • Builder Patterns: Fluent APIs for configuration throughout the framework

Testing

The framework provides comprehensive testing utilities in agents-test module:

LLM Response Mocking

val mockLLMApi = getMockExecutor(toolRegistry, eventHandler) {
    mockLLMAnswer("Hello!") onRequestContains "Hello"
    mockLLMToolCall(CreateTool, CreateTool.Args("solve")) onRequestEquals "Solve task"
    mockLLMAnswer("Default response").asDefaultResponse
}

Tool Behavior Mocking

// Simple return value
mockTool(PositiveToneTool) alwaysReturns "The text has a positive tone."

// With additional actions
mockTool(NegativeToneTool) alwaysTells {
    println("Tool called")
    "The text has a negative tone."
}

// Conditional responses
mockTool(SearchTool) returns SearchTool.Result("Found") onArgumentsMatching {
    args.query.contains("important")
}

Graph Structure Testing

AIAgent(...) {
    withTesting()

    testGraph("test") {
        val firstSubgraph = assertSubgraphByName<String, String>("first")
        val secondSubgraph = assertSubgraphByName<String, String>("second")

        assertEdges {
            startNode() alwaysGoesTo firstSubgraph
            firstSubgraph alwaysGoesTo secondSubgraph
        }

        verifySubgraph(firstSubgraph) {
            val askLLM = assertNodeByName<String, Message.Response>("callLLM")
            assertNodes {
                askLLM withInput "Hello" outputs Message.Assistant("Hello!")
            }
        }
    }
}

For comprehensive testing examples, see agents/agents-test/TESTING.md.

Security

API Key Management

  • NEVER commit API keys or secrets to the repository
  • Use environment variables for all sensitive configuration
  • Store test API keys in a local environment only
  • Required environment variables for integration tests:
    • ANTHROPIC_API_TEST_KEY
    • GEMINI_API_TEST_KEY
    • MISTRAL_AI_API_TEST_KEY
    • OLLAMA_IMAGE_URL
    • OPEN_AI_API_TEST_KEY
    • OPEN_ROUTER_API_TEST_KEY

Tool Execution Safety

  • Tools execute within controlled AIAgentEnvironment contexts
  • Direct tool calls are prevented outside agent execution
  • Use type-safe tool arguments to prevent injection attacks
  • Validate all external inputs in tool implementations

Dependency Security

  • Regularly update dependencies using Gradle version catalogs
  • Use specific version ranges to avoid supply chain attacks
  • Review dependencies for known vulnerabilities
  • Follow the principle of the least privilege in tool implementations

Configuration

Environment Setup

Set environment variables for integration testing (never commit API keys):

# Export in your shell or IDE run configuration
export ANTHROPIC_API_TEST_KEY=your_key_here
export DEEPSEEK_API_TEST_KEY=your_key_here
export GEMINI_API_TEST_KEY=your_key_here
export MISTRAL_AI_API_TEST_KEY=your_key_here
export OLLAMA_IMAGE_URL=http://localhost:11434
export OPEN_AI_API_TEST_KEY=your_key_here
export OPEN_ROUTER_API_TEST_KEY=your_key_here

# Or add to ~/.bashrc, ~/.zshrc, or IDE environment variables

Gradle Configuration

  • Uses version catalogs (gradle/libs.versions.toml) for dependency management
  • Multiplatform configuration in build.gradle.kts
  • Test configuration supports both JVM and JS targets

Development Environment Requirements

  • JDK: 17+ (OpenJDK recommended)
  • IDE: IntelliJ IDEA with Kotlin Multiplatform plugin
  • Optional: Docker for Ollama local testing

Development Workflow

Branch Strategy

  • develop: All development (features and bug fixes)
  • main: Released versions only
  • Base all PRs against develop branch
  • Use descriptive branch names: feature/agent-memory, fix/tool-registry-bug

Code Quality

  • ALWAYS run ./gradlew build before submitting PRs
  • Ensure all tests pass on JVM, JS, WASM targets
  • Follow established patterns in existing code
  • Add tests for new functionality
  • Update documentation for API changes

Commit Guidelines

  • Use conventional commit format: feat:, fix:, docs:, test:
  • Include issue references where applicable
  • Keep commits focused and atomic

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.