Introducing Koog Integration for Spring AI: Smarter Orchestration for Your Agents
Introducing Koog Integration for Spring AI: Smarter Orchestration for Your Agents 英文原文 Introducing Koog Integration for Spring AI: Smarter Orchestration for Your Agents > 作者: @jetbrains > 发布时间: 2026-04-16 > 原文链接: --- ## JetBrains AI Supercharge your tools with AI-powered features inside many JetBrains products Follow - Follow: - _RSS_ RSS Explore More # Introducing Koog Integr...
Introducing Koog Integration for Spring AI: Smarter Orchestration for Your Agents
英文原文
Introducing Koog Integration for Spring AI: Smarter Orchestration for Your Agents > 作者: @jetbrains > 发布时间: 2026-04-16 > 原文链接: https://blog.jetbrains.com/ai/2026/04/introducing-koog-integration-for-spring-ai-smarter-orchestration-for-your-agents/ --- ## JetBrains AI Supercharge your tools with AI-powered features inside many JetBrains products Follow - Follow: - _RSS_ RSSExplore More # Introducing Koog Integration for Spring AI: Smarter Orchestration for Your Agents Maria TiginaSergey Pestrikov April 16, 2026 Spring AI is the application-facing integration layer you may already use. Koog is the next layer up when you need agent orchestration. Spring AI already covers the chat model API, chat memory, and vector storage for RAG, and it provides Spring Boot starters with auto-configuration. Koog’s role is not to erase that, but rather to add a stronger agent runtime, offering: - Multi-step strategies and workflows for more precise control. - Persistence and checkpoints for fault-tolerant execution. - Sophisticated history management for cost-optimization. - Automated deterministic planning. You can now get the best of both worlds. Koog offers seamless Spring AI integration and can be easily layered on top as a higher-level agentic runtime. ## Spring AICopy heading link If you already use Spring AI, you’re familiar with its broad integration landscape: 13+ LLM providers, 18+ vector databases, and 10+ chat memory backends, all built seamlessly into the Spring ecosystem. Your application likely already relies on some of these integrations and wasn’t built in isolation. But as your agent’s complexity increases and business requirements demand more reliability, you start needing things that sit above the integration layer, for example, controlled execution logic, guardrails, fault tolerance, and cost optimization. These are the problems Koog was built to solve. CapabilitySpring AIKoogLLM providers ✅ 13+ ✅ 16+ Streaming ✅ Supported ✅ Supported Tool calling ✅ Supported ✅ Supported Database integrations ✅ 10+ (e.g. PostgreSQL and MongoDB) Uses the underlying ecosystem with a few integrations provided out of the box (e.g. Postgres) Vector databases ✅ 18+ (e.g. Milvus, Weaviate, and PGvector) ✅ Uses underlying integrations RAG (retrieval-augmented generation) ✅ Supported via advisors and VectorStore ✅ Supported and integrated into agent workflows Chat memory (short-term) ✅ Supported ✅ Supported Long-term memory ✅ Supported via vector DB integrations ✅ Built-in and pluggable (semantic and structured memory) Observability ✅ Basic observability from the Spring ecosystem (Micrometer, etc.), not tailored for LLM or AI observability tooling ✅ OpenTelemetry support, built-in tailored support for popular LLM or AI observability tooling (e.g. Langfuse, W&B Weave, and Datadog) Parallel execution ❌ Limited, manual ✅ Native (coroutines and concurrent node execution) Agent strategies ❌ Basic (prompt chaining and tool calling) ✅ Advanced type-safe graph workflows (multi-step reasoning, branching, tool orchestration, domain modeling approach), advanced planners (LLM-based and GOAP) Persistence ❌ Not built in, only the message history can be saved ✅ Built-in advanced persistence for the agent’s logic and state History compression ❌ Not built in ✅ Native support with out-of-the-box advanced strategies (summarization, pruning, and token optimization) The good news is you don’t have to choose one or the other, or dramatically change your existing setup to get there. Koog’s new Spring AI integration lets you keep your current LLM providers and databases exactly as they are, while writing your agents in Koog with minimal configuration changes. Your integration layer stays intact. Koog simply adds a powerful orchestration runtime on top of it. Let’s take a look at how it works. This post uses a Kotlin and Gradle setup for simplicity, but you can also use the recently released native Java Koog API (and, of course, Maven). ## Koog’s Spring AI integrationCopy heading link Let’s say your Spring project already uses three common Spring AI interfaces: ChatModel, ChatMemoryRepository, and VectorStore. Adding Koog on top is just a three-step process. Step 1: Keep your existing Spring AI dependencies. Plain text Copy to clipboard Open code in new window EnlighterJS 3 Syntax Highlighter // LLM implementation("org.springframework.ai:spring-ai-starter-model-openai") // Chat memory implementation("org.springframework.ai:spring-ai-starter-model-chat-memory-repository-jdbc") // Vector store implementation("org.springframework.ai:spring-ai-starter-vector-store-pgvector") // LLM implementation("org.springframework.ai:spring-ai-starter-model-openai") // Chat memory implementation("org.springframework.ai:spring-ai-starter-model-chat-memory-repository-jdbc") // Vector store implementation("org.springframework.ai:spring-ai-starter-vector-store-pgvector") // LLM implementation("org.springframework.ai:spring-ai-starter-model-openai") // Chat memory implementation("org.springframework.ai:spring-ai-starter-model-chat-memory-repository-jdbc") // Vector store implementation("org.springframework.ai:spring-ai-starter-vector-store-pgvector") Step 2: Add the Koog integration dependencies. Plain text Copy to clipboard Open code in new window EnlighterJS 3 Syntax Highlighter // Koog implementation("ai.koog:koog-agents-jvm:0.8.0") // Bridges ChatModel to Koog's LLMClient / PromptExecutor implementation("ai.koog:koog-spring-ai-starter-model-chat:0.8.0") // Bridges ChatMemoryRepository to Koog's ChatHistoryProvider implementation("ai.koog:koog-spring-ai-starter-chat-memory:0.8.0") // Bridges VectorStore to Koog's KoogVectorStore implementation("ai.koog:koog-spring-ai-starter-vector-store:0.8.0") // Koog implementation("ai.koog:koog-agents-jvm:0.8.0") // Bridges ChatModel to Koog's LLMClient / PromptExecutor implementation("ai.koog:koog-spring-ai-starter-model-chat:0.8.0") // Bridges ChatMemoryRepository to Koog's ChatHistoryProvider implementation("ai.koog:koog-spring-ai-starter-chat-memory:0.8.0") // Bridges VectorStore to Koog's KoogVectorStore implementation("ai.koog:koog-spring-ai-starter-vector-store:0.8.0") // Koog implementation("ai.koog:koog-agents-jvm:0.8.0") // Bridges ChatModel to Koog's LLMClient / PromptExecutor implementation("ai.koog:koog-spring-ai-starter-model-chat:0.8.0") // Bridges ChatMemoryRepository to Koog's ChatHistoryProvider implementation("ai.koog:koog-spring-ai-starter-chat-memory:0.8.0") // Bridges VectorStore to Koog's KoogVectorStore implementation("ai.koog:koog-spring-ai-starter-vector-store:0.8.0") Step 3: Use the auto-configured Koog beans. Each Koog starter automatically exposes a Spring bean that wraps your existing Spring AI bean: Spring AI interfaceKoog bean(s)ChatModelPromptExecutor, LLMClientChatMemoryRepositoryChatHistoryProviderVectorStoreKoogVectorStore The beans are auto-configured by default when there is a single matching Spring AI candidate, so your existing Spring AI application config stays untouched. That’s it for setup. Now let’s walk through what you can build. To make things concrete, we’ll use a customer support agent as our running example and progressively add capabilities. ## When a pure Spring AI agent reaches its limitCopy heading link One version of an agent that you could build in pure Spring AI would look like this: Plain text Copy to clipboard Open code in new window EnlighterJS 3 Syntax Highlighter @Service class CustomerSupportService( chatClientBuilder: ChatClient.Builder, vectorStore: VectorStore, chatMemory: ChatMemory, ) { // Build a fully configured ChatClient once at construction time private val chatClient: ChatClient = chatClientBuilder .defaultSystem(""" You are an e-commerce support assistant. Be concise and policy-aware. Never invent order data. If order context is missing for an order-specific request, ask for it. """.trimIndent()) .defaultAdvisors( // Vector store RAG advisor - enriches every prompt with relevant docs QuestionAnswerAdvisor( vectorStore, SearchRequest.builder() .topK(4) .similarityThreshold(0.7) .build() ), // Sliding-window chat memory advisor - keeps last N turns per session MessageChatMemoryAdvisor(chatMemory) ) .build() suspend fun createAndRunAgent(userPrompt: String, sessionId: String): String? = chatClient.prompt() .user(userPrompt) // Scope memory to session .advisorParam(ChatMemory.CONVERSATION\_ID, sessionId) .call() .tools() .content() } @Service class CustomerSupportService( chatClientBuilder: ChatClient.Builder, vectorStore: VectorStore, chatMemory: ChatMemory, ) { // Build a fully configured ChatClient once at construction time private val chatClient: ChatClient = chatClientBuilder .defaultSystem(""" You are an e-commerce support assistant. Be concise and policy-aware. Never invent order data. If order context is missing for an order-specific request, ask for it. """.trimIndent()) .defaultAdvisors( // Vector store RAG advisor - enriches every prompt with relevant docs QuestionAnswerAdvisor( vectorStore, SearchRequest.builder() .topK(4) .similarityThreshold(0.7) .build() ), // Sliding-window chat memory advisor - keeps last N turns per session MessageChatMemoryAdvisor(chatMemory) ) .build() suspend fun createAndRunAgent(userPrompt: String, sessionId: String): String? = chatClient.prompt() .user(userPrompt) // Scope memory to session .advisorParam(ChatMemory.CONVERSATION\_ID, sessionId) .call() .tools() .content() } @Service class CustomerSupportService( chatClientBuilder: ChatClient.Builder, vectorStore: VectorStore, chatMemory: ChatMemory, ) { // Build a fully configured ChatClient once at construction time private val chatClient: ChatClient = chatClientBuilder .defaultSystem(""" You are an e-commerce support assistant. Be concise and policy-aware. Never invent order data. If order context is missing for an order-specific request, ask for it. """.trimIndent()) .defaultAdvisors( // Vector store RAG advisor - enriches every prompt with relevant docs QuestionAnswerAdvisor( vectorStore, SearchRequest.builder() .topK(4) .similarityThreshold(0.7) .build() ), // Sliding-window chat memory advisor - keeps last N turns per session MessageChatMemoryAdvisor(chatMemory) ) .build() suspend fun createAndRunAgent(userPrompt: String, sessionId: String): String? = chatClient.prompt() .user(userPrompt) // Scope memory to session .advisorParam(ChatMemory.CONVERSATION\_ID, sessionId) .call() .tools() .content() } This agent implements a simple tool-calling loop that runs on top of the LLM defined in the config and inserted as a ChatClient. Besides this, the agent has two features. The first is QuestionAnswerAdvisor, which is built on top of VectorStore and behaves like RAG, enriching the conversation with relevant information from external docs. The second is ChatMemory, which keeps only a specified number of messages, helping you control the number of messages in a conversation and save tokens. But what if we don’t want a window of messages but a message history summary instead? Or, increasing complexity, what if, instead of a primitive tool-calling agentic loop, we wanted a more controllable and tailored strategy with different e-commerce support scenarios, or persistence and durable execution to make our agent fault-tolerant? This is where we reach the limits of Spring AI. But these, and many other agentic features, already exist in Koog and, thanks to the integration, they can easily be built on top of what you’ve already set up for Spring AI in your project. ## What does Koog’s Spring AI integration enable?Copy heading link First of all, this is what our e-commerce agent would look like in Koog. Plain text Copy to clipboard Open code in new window EnlighterJS 3 Syntax Highlighter @Service class CustomerSupportService( private val promptExecutor: PromptExecutor, private val chatStorage: ChatHistoryProvider, private val knowledgeBase: SearchStorage ) { suspend fun createAndRunAgent(userPrompt: String): String { val agentConfig = AIAgentConfig( prompt = prompt("ecommerce-support") { system( """ You are an e-commerce support assistant. Be concise and policy-aware. Never invent order data. If order context is missing for an order-specific request, ask for it. """.trimIndent() ) }, model = OpenAIModels.Chat.GPT5Nano, maxAgentIterations = 100 ) val toolRegistry = ToolRegistry { tools(EcommerceSupportTools()) } val agent = AIAgent( promptExecutor = promptExecutor, agentConfig = agentConfig, toolRegistry = toolRegistry, // Simple tool-calling loop strategy strategy = singeRunStrategy() ) { // Vector store RAG advisor - enriches every prompt with relevant docs install(LongTermMemory) { retrieval { storage = knowledgeBase searchStrategy = SimilaritySearchStrategy( topK = 4, similarityThreshold = 0.70 ) promptAugmenter = UserPromptAugmenter() } } // Sliding-window chat memory advisor - keeps last N turns per session install(ChatMemory) { chatHistoryProvider = chatStorage windowSize(20) } } return agent.run(userPrompt) } } @Service class CustomerSupportService( private val promptExecutor: PromptExecutor, private val chatStorage: ChatHistoryProvider, private val knowledgeBase: SearchStorage ) { suspend fun createAndRunAgent(userPrompt: String): String { val agentConfig = AIAgentConfig( prompt = prompt("ecommerce-support") { system( """ You are an e-commerce support assistant. Be concise and policy-aware. Never invent order data. If order context is missing for an order-specific request, ask for it. """.trimIndent() ) }, model = OpenAIModels.Chat.GPT5Nano, maxAgentIterations = 100 ) val toolRegistry = ToolRegistry { tools(EcommerceSupportTools()) } val agent = AIAgent( promptExecutor = promptExecutor, agentConfig = agentConfig, toolRegistry = toolRegistry, // Simple tool-calling loop strategy strategy = singeRunStrategy() ) { // Vector store RAG advisor - enriches every prompt with relevant docs install(LongTermMemory) { retrieval { storage = knowledgeBase searchStrategy = SimilaritySearchStrategy( topK = 4, similarityThreshold = 0.70 ) promptAugmenter = UserPromptAugmenter() } } // Sliding-window chat memory advisor - keeps last N turns per session install(ChatMemory) { chatHistoryProvider = chatStorage windowSize(20) } } return agent.run(userPrompt) } } @Service class CustomerSupportService( private val promptExecutor: PromptExecutor, private val chatStorage: ChatHistoryProvider, private val knowledgeBase: SearchStora
中文翻译
Introducing Koog Integration for Spring AI: Smarter Orchestration for Your Agents > 作者: @jetbrains > 发布时间: 2026-04-16 > 原文链接: https://blog.jetbrains.com/ai/2026/04/introducing-koog-integration-for-spring-ai-smarter-orchestration-for-your-agents/ --- ## JetBrains AI Supercharge your tools with AI-powered features inside many JetBrains products Follow - Follow: - _RSS_ RSSExplore More # Introducing Koog Integration for Spring AI: Smarter Orchestration for Your Agents Maria TiginaSergey Pestrikov April 16, 2026 Spring AI is the application-facing integration layer you may already use. Koog is the next layer up when you need agent orchestration. Spring AI already covers the chat model API, chat memory, and vector storage for RAG, and it provides Spring Boot starters with auto-configuration. Koog’s role is not to erase that, but rather to add a stronger agent runtime, offering: - Multi-step strategies and workflows for more precise control. - Persistence and checkpoints for fault-tolerant execution. - Sophisticated history management for cost-optimization. - Automated deterministic planning. You can now get the best of both worlds. Koog offers seamless Spring AI integration and can be easily layered on top as a higher-level agentic runtime. ## Spring AICopy heading link If you already use Spring AI, you’re familiar with its broad integration landscape: 13+ LLM providers, 18+ vector databases, and 10+ chat memory backends, all built seamlessly into the Spring ecosystem. Your application likely already relies on some of these integrations and wasn’t built in isolation. But as your agent’s complexity increases and business requirements demand more reliability, you start needing things that sit above the integration layer, for example, controlled execution logic, guardrails, fault tolerance, and cost optimization. These are the problems Koog was built to solve. CapabilitySpring AIKoogLLM providers ✅ 13+ ✅ 16+ Streaming ✅ Supported ✅ Supported Tool calling ✅ Supported ✅ Supported Database integrations ✅ 10+ (e.g. PostgreSQL and MongoDB) Uses the underlying ecosystem with a few integrations provided out of the box (e.g. Postgres) Vector databases ✅ 18+ (e.g. Milvus, Weaviate, and PGvector) ✅ Uses underlying integrations RAG (retrieval-augmented generation) ✅ Supported via advisors and VectorStore ✅ Supported and integrated into agent workflows Chat memory (short-term) ✅ Supported ✅ Supported Long-term memory ✅ Supported via vector DB integrations ✅ Built-in and pluggable (semantic and structured memory) Observability ✅ Basic observability from the Spring ecosystem (Micrometer, etc.), not tailored for LLM or AI observability tooling ✅ OpenTelemetry support, built-in tailored support for popular LLM or AI observability tooling (e.g. Langfuse, W&B Weave, and Datadog) Parallel execution ❌ Limited, manual ✅ Native (coroutines and concurrent node execution) Agent strategies ❌ Basic (prompt chaining and tool calling) ✅ Advanced type-safe graph workflows (multi-step reasoning, branching, tool orchestration, domain modeling approach), advanced planners (LLM-based and GOAP) Persistence ❌ Not built in, only the message history can be saved ✅ Built-in advanced persistence for the agent’s logic and state History compression ❌ Not built in ✅ Native support with out-of-the-box advanced strategies (summarization, pruning, and token optimization) The good news is you don’t have to choose one or the other, or dramatically change your existing setup to get there. Koog’s new Spring AI integration lets you keep your current LLM providers and databases exactly as they are, while writing your agents in Koog with minimal configuration changes. Your integration layer stays intact. Koog simply adds a powerful orchestration runtime on top of it. Let’s take a look at how it works. This post uses a Kotlin and Gradle setup for simplicity, but you can also use the recently released native Java Koog API (and, of course, Maven). ## Koog’s Spring AI integrationCopy heading link Let’s say your Spring project already uses three common Spring AI interfaces: ChatModel, ChatMemoryRepository, and VectorStore. Adding Koog on top is just a three-step process. Step 1: Keep your existing Spring AI dependencies. Plain text Copy to clipboard Open code in new window EnlighterJS 3 Syntax Highlighter // LLM implementation("org.springframework.ai:spring-ai-starter-model-openai") // Chat memory implementation("org.springframework.ai:spring-ai-starter-model-chat-memory-repository-jdbc") // Vector store implementation("org.springframework.ai:spring-ai-starter-vector-store-pgvector") // LLM implementation("org.springframework.ai:spring-ai-starter-model-openai") // Chat memory implementation("org.springframework.ai:spring-ai-starter-model-chat-memory-repository-jdbc") // Vector store implementation("org.springframework.ai:spring-ai-starter-vector-store-pgvector") // LLM implementation("org.springframework.ai:spring-ai-starter-model-openai") // Chat memory implementation("org.springframework.ai:spring-ai-starter-model-chat-memory-repository-jdbc") // Vector store implementation("org.springframework.ai:spring-ai-starter-vector-store-pgvector") Step 2: Add the Koog integration dependencies. Plain text Copy to clipboard Open code in new window EnlighterJS 3 Syntax Highlighter // Koog implementation("ai.koog:koog-agents-jvm:0.8.0") // Bridges ChatModel to Koog's LLMClient / PromptExecutor implementation("ai.koog:koog-spring-ai-starter-model-chat:0.8.0") // Bridges ChatMemoryRepository to Koog's ChatHistoryProvider implementation("ai.koog:koog-spring-ai-starter-chat-memory:0.8.0") // Bridges VectorStore to Koog's KoogVectorStore implementation("ai.koog:koog-spring-ai-starter-vector-store:0.8.0") // Koog implementation("ai.koog:koog-agents-jvm:0.8.0") // Bridges ChatModel to Koog's LLMClient / PromptExecutor implementation("ai.koog:koog-spring-ai-starter-model-chat:0.8.0") // Bridges ChatMemoryRepository to Koog's ChatHistoryProvider implementation("ai.koog:koog-spring-ai-starter-chat-memory:0.8.0") // Bridges VectorStore to Koog's KoogVectorStore implementation("ai.koog:koog-spring-ai-starter-vector-store:0.8.0") // Koog implementation("ai.koog:koog-agents-jvm:0.8.0") // Bridges ChatModel to Koog's LLMClient / PromptExecutor implementation("ai.koog:koog-spring-ai-starter-model-chat:0.8.0") // Bridges ChatMemoryRepository to Koog's ChatHistoryProvider implementation("ai.koog:koog-spring-ai-starter-chat-memory:0.8.0") // Bridges VectorStore to Koog's KoogVectorStore implementation("ai.koog:koog-spring-ai-starter-vector-store:0.8.0") Step 3: Use the auto-configured Koog beans. Each Koog starter automatically exposes a Spring bean that wraps your existing Spring AI bean: Spring AI interfaceKoog bean(s)ChatModelPromptExecutor, LLMClientChatMemoryRepositoryChatHistoryProviderVectorStoreKoogVectorStore The beans are auto-configured by default when there is a single matching Spring AI candidate, so your existing Spring AI application config stays untouched. That’s it for setup. Now let’s walk through what you can build. To make things concrete, we’ll use a customer support agent as our running example and progressively add capabilities. ## When a pure Spring AI agent reaches its limitCopy heading link One version of an agent that you could build in pure Spring AI would look like this: Plain text Copy to clipboard Open code in new window EnlighterJS 3 Syntax Highlighter @Service class CustomerSupportService( chatClientBuilder: ChatClient.Builder, vectorStore: VectorStore, chatMemory: ChatMemory, ) { // Build a fully configured ChatClient once at construction time private val chatClient: ChatClient = chatClientBuilder .defaultSystem(""" You are an e-commerce support assistant. Be concise and policy-aware. Never invent order data. If order context is missing for an order-specific request, ask for it. """.trimIndent()) .defaultAdvisors( // Vector store RAG advisor - enriches every prompt with relevant docs QuestionAnswerAdvisor( vectorStore, SearchRequest.builder() .topK(4) .similarityThreshold(0.7) .build() ), // Sliding-window chat memory advisor - keeps last N turns per session MessageChatMemoryAdvisor(chatMemory) ) .build() suspend fun createAndRunAgent(userPrompt: String, sessionId: String): String? = chatClient.prompt() .user(userPrompt) // Scope memory to session .advisorParam(ChatMemory.CONVERSATION\_ID, sessionId) .call() .tools() .content() } @Service class CustomerSupportService( chatClientBuilder: ChatClient.Builder, vectorStore: VectorStore, chatMemory: ChatMemory, ) { // Build a fully configured ChatClient once at construction time private val chatClient: ChatClient = chatClientBuilder .defaultSystem(""" You are an e-commerce support assistant. Be concise and policy-aware. Never invent order data. If order context is missing for an order-specific request, ask for it. """.trimIndent()) .defaultAdvisors( // Vector store RAG advisor - enriches every prompt with relevant docs QuestionAnswerAdvisor( vectorStore, SearchRequest.builder() .topK(4) .similarityThreshold(0.7) .build() ), // Sliding-window chat memory advisor - keeps last N turns per session MessageChatMemoryAdvisor(chatMemory) ) .build() suspend fun createAndRunAgent(userPrompt: String, sessionId: String): String? = chatClient.prompt() .user(userPrompt) // Scope memory to session .advisorParam(ChatMemory.CONVERSATION\_ID, sessionId) .call() .tools() .content() } @Service class CustomerSupportService( chatClientBuilder: ChatClient.Builder, vectorStore: VectorStore, chatMemory: ChatMemory, ) { // Build a fully configured ChatClient once at construction time private val chatClient: ChatClient = chatClientBuilder .defaultSystem(""" You are an e-commerce support assistant. Be concise and policy-aware. Never invent order data. If order context is missing for an order-specific request, ask for it. """.trimIndent()) .defaultAdvisors( // Vector store RAG advisor - enriches every prompt with relevant docs QuestionAnswerAdvisor( vectorStore, SearchRequest.builder() .topK(4) .similarityThreshold(0.7) .build() ), // Sliding-window chat memory advisor - keeps last N turns per session MessageChatMemoryAdvisor(chatMemory) ) .build() suspend fun createAndRunAgent(userPrompt: String, sessionId: String): String? = chatClient.prompt() .user(userPrompt) // Scope memory to session .advisorParam(ChatMemory.CONVERSATION\_ID, sessionId) .call() .tools() .content() } This agent implements a simple tool-calling loop that runs on top of the LLM defined in the config and inserted as a ChatClient. Besides this, the agent has two features. The first is QuestionAnswerAdvisor, which is built on top of VectorStore and behaves like RAG, enriching the conversation with relevant information from external docs. The second is ChatMemory, which keeps only a specified number of messages, helping you control the number of messages in a conversation and save tokens. But what if we don’t want a window of messages but a message history summary instead? Or, increasing complexity, what if, instead of a primitive tool-calling agentic loop, we wanted a more controllable and tailored strategy with different e-commerce support scenarios, or persistence and durable execution to make our agent fault-tolerant? This is where we reach the limits of Spring AI. But these, and many other agentic features, already exist in Koog and, thanks to the integration, they can easily be built on top of what you’ve already set up for Spring AI in your project. ## What does Koog’s Spring AI integration enable?Copy heading link First of all, this is what our e-commerce agent would look like in Koog. Plain text Copy to clipboard Open code in new window EnlighterJS 3 Syntax Highlighter @Service class CustomerSupportService( private val promptExecutor: PromptExecutor, private val chatStorage: ChatHistoryProvider, private val knowledgeBase: SearchStorage ) { suspend fun createAndRunAgent(userPrompt: String): String { val agentConfig = AIAgentConfig( prompt = prompt("ecommerce-support") { system( """ You are an e-commerce support assistant. Be concise and policy-aware. Never invent order data. If order context is missing for an order-specific request, ask for it. """.trimIndent() ) }, model = OpenAIModels.Chat.GPT5Nano, maxAgentIterations = 100 ) val toolRegistry = ToolRegistry { tools(EcommerceSupportTools()) } val agent = AIAgent( promptExecutor = promptExecutor, agentConfig = agentConfig, toolRegistry = toolRegistry, // Simple tool-calling loop strategy strategy = singeRunStrategy() ) { // Vector store RAG advisor - enriches every prompt with relevant docs install(LongTermMemory) { retrieval { storage = knowledgeBase searchStrategy = SimilaritySearchStrategy( topK = 4, similarityThreshold = 0.70 ) promptAugmenter = UserPromptAugmenter() } } // Sliding-window chat memory advisor - keeps last N turns per session install(ChatMemory) { chatHistoryProvider = chatStorage windowSize(20) } } return agent.run(userPrompt) } } @Service class CustomerSupportService( private val promptExecutor: PromptExecutor, private val chatStorage: ChatHistoryProvider, private val knowledgeBase: SearchStorage ) { suspend fun createAndRunAgent(userPrompt: String): String { val agentConfig = AIAgentConfig( prompt = prompt("ecommerce-support") { system( """ You are an e-commerce support assistant. Be concise and policy-aware. Never invent order data. If order context is missing for an order-specific request, ask for it. """.trimIndent() ) }, model = OpenAIModels.Chat.GPT5Nano, maxAgentIterations = 100 ) val toolRegistry = ToolRegistry { tools(EcommerceSupportTools()) } val agent = AIAgent( promptExecutor = promptExecutor, agentConfig = agentConfig, toolRegistry = toolRegistry, // Simple tool-calling loop strategy strategy = singeRunStrategy() ) { // Vector store RAG advisor - enriches every prompt with relevant docs install(LongTermMemory) { retrieval { storage = knowledgeBase searchStrategy = SimilaritySearchStrategy( topK = 4, similarityThreshold = 0.70 ) promptAugmenter = UserPromptAugmenter() } } // Sliding-window chat memory advisor - keeps last N turns per session install(ChatMemory) { chatHistoryProvider = chatStorage windowSize(20) } } return agent.run(userPrompt) } } @Service class CustomerSupportService( private val promptExecutor: PromptExecutor, private val chatStorage: ChatHistoryProvider, private val knowledgeBase: SearchStora