Predefined Strategies
Koog provides two built-in agent strategies that cover the most common agent patterns.
Overview
| Strategy | Pattern | Best For |
|---|---|---|
chatAgentStrategy() |
Conversational loop with tool enforcement | Chatbots, Q&A, general assistants |
reActStrategy() |
Reason → Act → Observe cycle | Complex multi-step tasks, analysis |
Chat Agent Strategy
A conversational agent that processes user input, calls tools when needed, and returns responses. Enforces tool usage over plain-text answers.
Dependency
import ai.koog.agents.ext.agent.chatAgentStrategy
Kotlin Setup
import ai.koog.agents.ext.agent.chatAgentStrategy
import ai.koog.agents.core.agent.AIAgent
import ai.koog.agents.core.tools.ToolRegistry
import ai.koog.agents.ext.simple.simpleOpenAIExecutor
import ai.koog.agents.ext.llm.OpenAIModels
val chatAgent = AIAgent(
promptExecutor = simpleOpenAIExecutor(System.getenv("OPENAI_API_KEY")),
llmModel = OpenAIModels.Chat.GPT4o,
strategy = chatAgentStrategy(),
toolRegistry = ToolRegistry {
tool(searchTool)
tool(weatherTool)
}
)
val result = chatAgent.run("What's the weather like today?")
Java Setup
import ai.koog.agents.ext.agent.AIAgentStrategies;
import ai.koog.agents.core.agent.AIAgent;
import ai.koog.agents.core.tools.ToolRegistry;
import ai.koog.agents.ext.simple.SimpleOpenAIExecutorKt;
import ai.koog.agents.ext.llm.OpenAIModels;
ToolRegistry toolRegistry = ToolRegistry.builder()
.tools(new SearchAndWeatherTools())
.build();
AIAgent<String, String> chatAgent = AIAgent.builder()
.promptExecutor(SimpleOpenAIExecutorKt.simpleOpenAIExecutor(
System.getenv("OPENAI_API_KEY")))
.llmModel(OpenAIModels.Chat.GPT4o)
.graphStrategy(AIAgentStrategies.chatAgentStrategy())
.toolRegistry(toolRegistry)
.build();
String result = chatAgent.run("What's the weather like today?");
How It Works
User Input → LLM Processing → Tool Call? → Execute Tool → Loop Back
↓ No
Response
- User sends a message
- LLM processes the message with available tools
- If LLM requests tool calls → execute tools → send results back to LLM
- Repeat until LLM produces a final text response
- Provides feedback if the LLM tries to respond with plain text instead of using tools
Best Use Cases
- Conversational agents requiring tool access
- Assistants performing actions on user requests
- Chatbots accessing external systems or data
- Situations enforcing tool usage over plain text
ReAct Strategy (Reasoning and Acting)
Alternates between reasoning and execution stages in a loop: Reason → Act → Observe → repeat until complete.
Dependency
import ai.koog.agents.ext.agent.reActStrategy
Kotlin Setup
import ai.koog.agents.ext.agent.reActStrategy
import ai.koog.agents.core.agent.AIAgent
import ai.koog.agents.core.tools.ToolRegistry
import ai.koog.agents.ext.simple.simpleOpenAIExecutor
import ai.koog.agents.ext.llm.OpenAIModels
val reActAgent = AIAgent(
promptExecutor = simpleOpenAIExecutor(apiKey),
llmModel = OpenAIModels.Chat.GPT4o,
strategy = reActStrategy(
reasoningInterval = 1,
name = "banking_agent"
),
toolRegistry = ToolRegistry {
tool(getTransactions)
tool(calculateSum)
}
)
val result = reActAgent.run("How much did I spend last month?")
Java Setup
AIAgent<String, String> reActAgent = AIAgent.<String, String>builder()
.promptExecutor(SimpleOpenAIExecutorKt.simpleOpenAIExecutor(
System.getenv("OPENAI_API_KEY")))
.llmModel(OpenAIModels.Chat.GPT4o)
.graphStrategy(AIAgentStrategies.reActStrategy(1, "banking_agent"))
.toolRegistry(ToolRegistry.builder()
.tools(new BankingTools())
.build())
.build();
String result = reActAgent.run("How much did I spend last month?");
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
reasoningInterval |
Int |
1 |
Interval for reasoning steps; must be > 0 |
name |
String |
"re_act" |
The strategy name for tracing |
How It Works
User Question
↓
┌─── Reason: Plan next step ───┐
│ │
├─── Act: Call a tool ──────────┤
│ │
├─── Observe: Tool result ──────┤
│ │
└─── (repeat until solved) ─────┘
↓
Final Answer
Banking Example Trace
User: "How much did I spend last month?"
- Reason: I need to get transactions, filter deposits, then calculate the sum
- Act:
get_transactions(startDate: "2025-05-19", endDate: "2025-06-18") - Observe: Returns transaction records including positive (deposits) and negative (spending)
- Reason: I need to remove the salary deposit and sum remaining transactions
- Act:
calculate_sum(amounts: [-100.00, -500.00, -200.00]) - Observe: Result:
-800.00 - Final: "You spent $800.00 last month on groceries, rent, and utilities."
Best Use Cases
- Complex tasks requiring multistep reasoning
- Scenarios where the agent gathers information before answering
- Problems benefiting from decomposition into smaller steps
- Tasks combining analytical thinking with tool usage
When to Use Each
| Scenario | Recommended Strategy |
|---|---|
| Simple Q&A with tools | chatAgentStrategy() |
| Multi-step analysis | reActStrategy() |
| Data processing pipeline | reActStrategy() |
| Conversational chatbot | chatAgentStrategy() |
| Research tasks | reActStrategy() |
| Quick lookups | chatAgentStrategy() |
Key Differences
| Aspect | Chat Agent | ReAct |
|---|---|---|
| Pattern | Input → LLM → Tool/Response loop | Reason → Act → Observe cycle |
| Reasoning | Implicit (LLM decides) | Explicit, structured reasoning steps |
| Parameters | None configurable | reasoningInterval, name |
| Complexity | Simpler conversational flows | Multi-step complex tasks |
| Import | chatAgentStrategy() |
reActStrategy() |
| Java | AIAgentStrategies.chatAgentStrategy() |
AIAgentStrategies.reActStrategy(...) |