사전 정의된 에이전트 전략
원문: Koog Documentation — predefined-agent-strategies 이 글은 Koog 공식 문서의 predefined-agent-strategies 페이지를 한국어로 옮긴 번역본입니다. 문서 구조와 링크 의미를 유지하되, MkDocs 전용 UI 문법은 블로그에서 읽기 좋도록 정리했습니다.
사전 정의된 에이전트 전략
에이전트 구현을 더 쉽게 만들기 위해 Koog는 일반적인 에이전트 사용 사례에 대해 사전 정의된 에이전트 전략을 제공합니다. 다음과 같은 사전 정의된 전략을 사용할 수 있습니다.
채팅 상담원 전략
채팅 상담원 전략은 채팅 상호작용 프로세스를 실행하기 위해 설계되었습니다. 다양한 단계, 노드 및 도구 간의 상호 작용을 조율하여 사용자 입력을 처리하고, 도구를 실행하고, 채팅과 같은 방식으로 응답을 제공합니다.
개요
Chat 상담원 전략은 상담원이 다음을 수행하는 패턴을 구현합니다.
- 사용자 입력을 받습니다
- LLM을 사용하여 입력을 처리합니다.
- 도구를 호출하거나 직접 응답을 제공합니다.
- 도구 결과를 처리하고 대화를 계속합니다.
- LLM이 도구를 사용하는 대신 일반 텍스트로 응답하려고 하면 피드백을 제공합니다.
이 접근 방식은 에이전트가 도구를 사용하여 사용자 요청을 이행할 수 있는 대화형 인터페이스를 만듭니다.
설정 및 종속성
Koog에서 채팅 에이전트 전략의 구현은 chatAgentStrategy 기능을 통해 수행됩니다. 에이전트 코드에서 이 기능을 사용할 수 있게 하려면 다음 종속성 가져오기를 추가하세요.
1ai.koog.agents.ext.agent.chatAgentStrategy전략을 사용하려면 아래 패턴에 따라 AI 에이전트를 만듭니다.
코틀린
1val chatAgent = AIAgent(2 promptExecutor = promptExecutor,3 toolRegistry = toolRegistry,4 llmModel = model,5 // Set chatAgentStrategy as the agent strategy6 strategy = chatAgentStrategy()7)자바
1AIAgent<String, String> chatAgent = AIAgent.builder()2 .promptExecutor(PromptExecutor.builder().openAI("OPENAI_API_KEY").build())3 .llmModel(OpenAIModels.Chat.O4Mini)4 .toolRegistry(ToolRegistry.builder().build())5 // Set chatAgentStrategy as the agent strategy6 .graphStrategy(AIAgentStrategies.chatAgentStrategy())7 .build();Chat 상담원 전략을 사용해야 하는 경우
Chat 상담원 전략은 특히 다음과 같은 경우에 유용합니다.
- 도구를 사용해야 하는 대화형 에이전트 구축
- 사용자 요청에 따라 작업을 수행할 수 있는 어시스턴트 만들기
- 외부 시스템이나 데이터에 접근해야 하는 챗봇 구현
- 일반 텍스트 응답 대신 도구 사용을 적용하려는 시나리오
예
다음은 사전 정의된 Chat 에이전트 전략(chatAgentStrategy)과 에이전트가 사용할 수 있는 도구를 구현하는 AI 에이전트의 코드 샘플입니다.
코틀린
1val chatAgent = AIAgent(2 promptExecutor = promptExecutor,3 llmModel = model,4 // Use chatAgentStrategy as the agent strategy5 strategy = chatAgentStrategy(),6 // Add tools the agent can use7 toolRegistry = ToolRegistry {8 tool(searchTool)9 tool(weatherTool)10 }11)1213suspend fun main() { 14 // Run the agent with a user query15 val result = chatAgent.run("What's the weather like today and should I bring an umbrella?")16}자바
1// Add tools the agent can use2ToolRegistry toolRegistry = ToolRegistry.builder()3 .tools(new SearchAndWeatherTools())4 .build();56AIAgent<String, String> chatAgent = AIAgent.builder()7 .promptExecutor(PromptExecutor.builder().openAI("OPENAI_API_KEY").build())8 .llmModel(OpenAIModels.Chat.O4Mini)9 // Use chatAgentStrategy as the agent strategy10 .graphStrategy(AIAgentStrategies.chatAgentStrategy())11 .toolRegistry(toolRegistry)12 .build();1314// Run the agent with a user query15String result = chatAgent.run("What's the weather like today and should I bring an umbrella?");리액트 전략
ReAct(Reasoning and Acting) 전략은 추론과 실행 단계를 번갈아 가며 작업을 동적으로 처리하고 LLM(Large Language Model)의 출력을 요청하는 AI 에이전트 전략입니다.
개요
ReAct 전략은 에이전트가 다음을 수행하는 패턴을 구현합니다.
- 현재 상태에 대한 이유와 다음 단계 계획
- 그 추론에 따라 조치를 취합니다.
- 그 행동의 결과를 관찰한다
- 사이클을 반복합니다
이 접근 방식은 추론(단계적으로 문제를 통해 생각)과 실행(정보를 수집하거나 작업을 수행하기 위한 도구 실행)의 강점을 결합합니다.
흐름도
ReAct 전략의 흐름도는 다음과 같습니다.

설정 및 종속성
Koog에서 ReAct 전략의 구현은 reActStrategy 기능을 통해 수행됩니다.
전략을 사용하려면 아래 패턴에 따라 AI 에이전트를 만듭니다.
코틀린
1val reActAgent = AIAgent(2 promptExecutor = promptExecutor,3 toolRegistry = toolRegistry,4 llmModel = model,5 // Set reActStrategy as the agent strategy6 strategy = reActStrategy(7 // Set optional parameter values8 reasoningInterval = 1,9 name = "react_agent"10 )11)자바
1AIAgent<String, String> reActAgent = AIAgent.builder()2 .promptExecutor(PromptExecutor.builder().openAI("OPENAI_API_KEY").build())3 .llmModel(OpenAIModels.Chat.O4Mini)4 .toolRegistry(ToolRegistry.builder().build())5 // Set reActStrategy as the agent strategy6 .graphStrategy(AIAgentStrategies.reActStrategy(7 // Set optional parameter values8 1, // reasoningInterval9 "react_agent" // name10 ))11 .build();매개변수
reActStrategy 함수는 다음 매개변수를 사용합니다.
| 매개변수 | 유형 | 기본 | 설명 |
|---|---|---|---|
reasoningInterval |
정수 | 1 | 추론 단계의 간격을 지정합니다. 0보다 커야 합니다. |
name |
끈 | re_act |
전략의 이름입니다. |
사용 사례 예시
다음은 ReAct 전략이 간단한 은행 에이전트와 어떻게 작동하는지에 대한 예입니다.
1. 사용자 입력
사용자가 초기 프롬프트를 보냅니다. 예를 들어 How much did I spend last month?과 같은 질문이 될 수 있습니다.
2. 추론
에이전트는 사용자 입력과 추론 프롬프트를 받아 초기 추론을 수행합니다. 추론은 다음과 같이 보일 수 있습니다. 다음과 같습니다:
1I need to follow these steps:21. Get all transactions from last month32. Filter out deposits (positive amounts)43. Calculate total spending3. 행동과 실행, 1단계
에이전트가 이전 단계에서 정의한 작업 항목을 기반으로 도구를 실행하여 모든 트랜잭션을 가져옵니다. 지난달부터.
이 경우 실행할 도구는 정의된 startDate 및 endDate 인수와 함께 get_transactions입니다.
지난 달의 모든 거래를 가져오려면 요청을 일치시키세요.
1{tool: "get_transactions", args: {startDate: "2025-05-19", endDate: "2025-06-18"}}이 도구는 다음과 같은 결과를 반환합니다.
1[2 {date: "2025-05-25", amount: -100.00, description: "Grocery Store"},3 {date: "2025-05-31", amount: +1000.00, description: "Salary Deposit"},4 {date: "2025-06-10", amount: -500.00, description: "Rent Payment"},5 {date: "2025-06-13", amount: -200.00, description: "Utilities"}6]4. 추론
도구에서 반환된 결과를 사용하여 에이전트는 흐름의 다음 단계를 결정하기 위해 다시 추론을 수행합니다.
1I have the transactions. Now I need to:21. Remove the salary deposit of +1000.0032. Sum up the remaining transactions5. 행동과 실행, 2단계
이전 추론 단계를 기반으로 에이전트는 다음과 같이 제공된 금액을 합산하는 calculate_sum 도구를 호출합니다.
도구 인수. 그 추론 역시 거래에서 플러스 금액을 제거하는 액션 포인트로 이어졌기 때문에,
도구 인수로 제공된 금액은 음수입니다.
1{tool: "calculate_sum", args: {amounts: [-100.00, -500.00, -200.00]}}도구는 최종 결과를 반환합니다.
1-800.006. 최종 답변
에이전트는 계산된 합계를 포함하는 최종 응답(보조 메시지)을 반환합니다.
1You spent $800.00 last month on groceries, rent, and utilities.ReAct 전략을 사용해야 하는 경우
ReAct 전략은 특히 다음과 같은 경우에 유용합니다.
- 다단계 추론이 필요한 복잡한 작업
- 상담원이 최종 답변을 제공하기 전에 정보를 수집해야 하는 시나리오
- 더 작은 단계로 분해하면 도움이 되는 문제
- 분석적 사고와 도구 활용이 모두 필요한 작업
예
다음은 사전 정의된 ReAct 전략(reActStrategy)을 구현하는 AI 에이전트의 코드 샘플과 다음을 수행하는 도구입니다.
상담원은 다음을 사용할 수 있습니다.
코틀린
1val bankingAgent = AIAgent(2 promptExecutor = promptExecutor,3 llmModel = model,4 // Use reActStrategy as the agent strategy5 strategy = reActStrategy(6 reasoningInterval = 1,7 name = "banking_agent"8 ),9 // Add tools the agent can use10 toolRegistry = ToolRegistry {11 tool(getTransactions)12 tool(calculateSum)13 }14)1516suspend fun main() { 17 // Run the agent with a user query18 val result = bankingAgent.run("How much did I spend last month?")19}자바
1// Add tools the agent can use2ToolRegistry toolRegistry = ToolRegistry.builder()3 .tools(new BankingTools())4 .build();56AIAgent<String, String> bankingAgent = AIAgent.<String, String>builder()7 .promptExecutor(PromptExecutor.builder().openAI("OPENAI_API_KEY").build())8 .llmModel(OpenAIModels.Chat.O4Mini)9 // Use reActStrategy as the agent strategy10 .graphStrategy(AIAgentStrategies.reActStrategy(1, "banking_agent"))11 .toolRegistry(toolRegistry)12 .build();1314// Run the agent with a user query15String result = bankingAgent.run("How much did I spend last month?");