How jetbrains/koog works
Project type and purpose
• This is a Kotlin Multiplatform framework/library (not an end‐user application) designed to build AI agents in idiomatic Kotlin.
• It exposes modular components (subprojects) for core agent logic, tool integration, features (memory, tracing, event handling, etc.), embeddings, prompt modeling/execution, and prompt caching.
File structure
• Top‐level Gradle multiproject: agents, embeddings, prompt, prompt-executor, prompt-cache, examples, integration-tests, plus numerous submodules under each.
• agents/agents-core: core domain model (agents, contexts, state graph, engine).
• agents/agents-ext, agents/agents-features-*, agents/agents-tools, agents/agents-utils, agents/agents-test, agents/agents-mcp: extension points, feature implementations, tool registry, testing helpers, MCP integration.
• embeddings/*: base vector abstraction and LLM‐backed embeddings.
• prompt/*: DSLs, models, markdown/XML helpers, structured prompts.
• prompt-executor/*: abstract executor model, caching wrapper, LLM client adapters (OpenAI, Anthropic, Google, Ollama, OpenRouter), multi‐LLM orchestrator.
• prompt-cache/*: in-memory, file, Redis caches.
• Build scripts (build.gradle.kts, settings.gradle.kts), buildSrc with shared Gradle logic.
• examples/ and integration-tests/ illustrate usage and validate end-to-end behavior.
README for additional insights
• Confirms modularity and multiplatform support (JVM, JS).
• Highlights core domains: agent, tool, memory, trace, embeddings, prompt‐execution.
• Mentions external services: OpenAI, Anthropic, Google, OpenRouter, Ollama via a “Model Control Protocol (MCP)” adapter.
Elements
• Labels for each component/module group
• Core modules (Agent Core, Prompt Model)
• Feature modules (Memory, Tracing)
• External services (OpenAI, Redis)
• Platform‐specific code
Detailed capture of essential architecture
• Do not overpartition: cluster related modules (e.g., all prompt-executor‐clients together).
• Both static structure (module clusters) and dynamic flow (sequence of calls).
• Extension points: “ToolRegistry” interface, “Feature” hook interfaces, “LLMClient” interface.
• Build‐time vs runtime: Gradle multiproject boundaries vs in‐process modules.