ReAct 및 계획-실행 에이전트
복잡한 작업을 완료하기 위해 추론과 행동을 결합하는 고급 에이전트 아키텍처를 이해하고 구현합니다.
ReAct 및 계획-실행 에이전트은(는) CoddyKit의 무료 AI Agents with LangChain & Autonomous Workflows 강의입니다. 이것은 6개 중 1번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 AI Agents with LangChain & Autonomous Workflows 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. AI Agents with LangChain & Autonomous Workflows 강의에는 총 6개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
Beyond Simple AI Agents
Welcome to Advanced Agent Architectures! So far, you've learned about basic agents and chains in LangChain. These are great for straightforward tasks.
However, real-world problems can be complex. They often require agents to reason, make decisions, and perform multiple steps to achieve a goal. This is where advanced architectures come in.
Introducing ReAct Agents
One powerful advanced architecture is ReAct, which stands for Reasoning and Acting. It's inspired by how humans solve problems.
- Reasoning: The agent thinks about the problem, current state, and what to do next.
- Acting: The agent then performs an action, often by using a tool.
This cycle allows agents to dynamically adapt and solve complex tasks.
The ReAct Loop: Thought, Action, Observation
ReAct agents operate in an iterative loop:
- Thought: The agent generates a thought, explaining its reasoning and what it plans to do.
- Action: Based on the thought, the agent chooses a tool and its input (e.g., 'search', 'calculator').
- Observation: The agent receives the result from the tool's execution.
This loop continues until the agent believes it has enough information to provide a final answer.
ReAct in Action: A Simple Flow
Let's see a simplified Python example of how a ReAct agent's logic might flow. Notice how it thinks, acts, and observes to reach a conclusion.
def run_react_agent(query):
print(f"User Query: {query}")
print("Thought: I need to find the population of London. I will use a search tool.")
print("Action: Use 'search_tool' with query 'population of London'")
# Simulate tool output
observation = "Observation: The population of London is ~9 million (2023 est.)."
print(observation)
print("Thought: I have the information. I can now answer the user.")
print("Action: Respond with the observed information.")
return observation.replace("Observation: ", "")
if __name__ == "__main__":
result = run_react_agent("What is the population of London?")
print(f"\nFinal Answer: {result}")Understanding Plan-and-Execute
Another powerful architecture is Plan-and-Execute. Unlike ReAct, which is more reactive, Plan-and-Execute agents first create a comprehensive plan.
They are particularly effective for tasks that are complex, multi-step, and where a clear sequence of actions can be determined upfront.
The Planner and Executor Components
Plan-and-Execute agents typically consist of two main parts:
- The Planner: This component takes the initial goal and breaks it down into a sequence of smaller, manageable steps. It focuses on strategy.
- The Executor: This component then takes each step from the plan and carries it out, often by using specific tools. It focuses on execution.
This separation helps manage complexity and ensures a structured approach.
Plan-and-Execute: A Structured Flow
Here's a simplified Python example illustrating the Plan-and-Execute flow. Notice how the goal is first planned, then each step is executed in order.
def planner(goal):
print(f"Goal: {goal}")
print("Planner: Breaking down the goal into steps...")
plan = [
"Step 1: Find today's date.",
"Step 2: Get the weather forecast for New York City for today.",
"Step 3: Summarize the date and weather information."
]
print(f"Plan created: {plan}")
return plan
def executor(step):
print(f"Executing: {step}")
if "date" in step:
return "Observation: Today's date is October 26, 2023."
elif "weather" in step:
return "Observation: New York weather: Sunny, 60°F."
elif "summarize" in step:
return "Observation: Summary: Oct 26, 2023, NYC is Sunny, 60°F."
return "Observation: Step completed."
if __name__ == "__main__":
my_goal = "Tell me today's date and weather in New York City."
plan_steps = planner(my_goal)
print("\n--- Execution Phase ---")
for step in plan_steps:
res = executor(step)
print(res)ReAct vs. Plan-and-Execute
Both are powerful, but suited for different scenarios:
- ReAct: More dynamic and reactive. Best for tasks where the path isn't clear upfront, requiring exploration and iterative decision-making (e.g., complex research questions).
- Plan-and-Execute: More structured and systematic. Best for tasks where a clear sequence of steps can be defined (e.g., booking a flight with known steps: search, select, confirm).
Choosing the Right Architecture
When deciding between ReAct and Plan-and-Execute, consider:
- Task Complexity: Is it a clear, sequential task (Plan-and-Execute) or an exploratory, problem-solving one (ReAct)?
- Predictability: Can you easily predict the steps needed (Plan-and-Execute) or will the agent need to adapt dynamically (ReAct)?
- Error Handling: Plan-and-Execute can sometimes be easier to debug due to defined steps, while ReAct's dynamic nature can be harder to trace.
Quick Check: Agent Architectures
An AI agent needs to solve a complex, multi-step problem where the exact sequence of actions is not known beforehand, and it might need to explore different options and react to intermediate results.
Recap: Advanced Agent Architectures
Great job! In this lesson, you explored two advanced agent architectures:
- ReAct (Reasoning and Acting): Agents that iteratively think, act, and observe, suitable for dynamic, exploratory tasks.
- Plan-and-Execute: Agents that first create a detailed plan and then execute each step, ideal for structured, multi-step workflows.
Understanding these patterns helps you build more robust and intelligent AI agents for complex challenges. Next, we'll look at agents that can self-correct!
자주 묻는 질문
“ReAct 및 계획-실행 에이전트” 강의는 무료인가요?
네 — “ReAct 및 계획-실행 에이전트” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 AI Agents with LangChain & Autonomous Workflows 강의 전체를 잠금 해제할 수 있습니다. AI Agents with LangChain & Autonomous Workflows 강의에는 총 6개의 강의가 포함되어 있습니다.
“ReAct 및 계획-실행 에이전트”에서 뭘 배우나요?
복잡한 작업을 완료하기 위해 추론과 행동을 결합하는 고급 에이전트 아키텍처를 이해하고 구현합니다. 브라우저에서 직접 실행하는 실습 코드로 AI Agents with LangChain & Autonomous Workflows을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
AI Agents with LangChain & Autonomous Workflows을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 AI Agents with LangChain & Autonomous Workflows은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 6개 중 1번째 강의입니다.
“ReAct 및 계획-실행 에이전트” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 AI Agents with LangChain & Autonomous Workflows 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 AI Agents with LangChain & Autonomous Workflows 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- ReAct 및 계획-실행 에이전트
- 계층적 에이전트 설계
- 자기 교정 및 성찰 에이전트
- 에이전트를 위한 인지 아키텍처
- 다중 에이전트 협업 패턴
- 하이브리드 에이전트 시스템