AI.zip
  • AI 모델
  • 방법론
  • AI 서비스
  • 가격 비교
  • 블로그

AI.zip

AI 모델, 서비스, 방법론을 큐레이션하는 에디토리얼 플랫폼

탐색

  • AI 모델
  • AI 서비스
  • 방법론
  • 블로그

커뮤니티

  • 소개
  • 디스코드 참여
  • 문의

법적고지

  • 이용약관
  • 개인정보처리방침

© 2026 ai.zip. All rights reserved.

Discord 커뮤니티
방법론ReAct (Reasoning + Acting)

ReAct (Reasoning + Acting)

쉽게 이해하기

형사가 사건을 수사하는 장면을 떠올려보자. 단순히 머릿속으로만 추리하는 탐정은 결국 틀린 결론에 빠지기 쉽다. 반대로 아무 생각 없이 현장을 뛰어다니기만 하는 수사관도 단서를 놓친다. 뛰어난 형사는 "이 혈흔의 위치로 보아 범인은 왼손잡이일 것이다(추론) → 용의자 명단에서 왼손잡이를 조회한다(행동) → 세 명이 검색됐다(관찰) → 그중 현장에 있었던 인물을 확인한다(추론) → 목격자 진술을 검색한다(행동)"는 식으로 생각과 행동을 교차한다.

ReAct는 이 패턴을 AI에 적용한 프레임워크다. 기존 언어 모델은 질문을 받으면 학습된 지식만으로 답을 생성했다. 지식 컷오프 이후의 사실, 실시간 날씨, 특정 데이터베이스의 수치는 알 수 없었다. ReAct는 이 한계를 "중간에 도구를 쓰면 되잖아?"라는 단순한 발상으로 깬다. 모델이 추론 단계에서 "이건 위키피디아를 검색해야 해"라고 판단하면 실제로 검색 API를 호출하고, 결과를 받아 다음 추론을 이어간다.

실생활에서 가장 가까운 예시는 스마트폰을 든 사람이다. 어떤 질문을 받았을 때 순수하게 기억에 의존하는 사람보다, 필요한 순간에 검색하고 계산기를 켜고 지도를 확인하면서 답하는 사람이 훨씬 정확하다. ReAct는 AI가 "언제 도구를 쓸지 스스로 판단하는 능력"을 갖추게 만든 설계 원칙이다.

기술 심층 분석

핵심 아키텍처

ReAct는 Shunyu Yao, Jeffrey Zhao, Dian Yu, Nan Du, Izhak Shafran, Karthik Narasimhan, Yuan Cao가 2022년 발표한 논문 "ReAct: Synergizing Reasoning and Acting in Language Models"에서 제안됐다.1 Google Brain과 Princeton University의 공동 연구로, ICLR 2023에 게재됐다.

핵심 아이디어는 언어 모델의 행동 공간(action space)을 기존 태스크 전용 행동뿐 아니라 자연어 추론 트레이스(thought trace)까지 확장하는 것이다.

기본 루프 구조:

Thought_t  : 현재 상태에 대한 추론, 다음 행동 계획
Action_t   : 외부 환경(도구, API)에 대한 호출
Observation_t : 행동의 결과

이 세 요소가 반복되며 최종 답에 도달한다:

(o_1, ..., o_t) -> Thought_t -> Action_t -> Observation_t
                   -> Thought_{t+1} -> Action_{t+1} -> ...
                   -> Action_finish(answer)

POMDP 관점의 정형화:

ReAct는 부분 관찰 마르코프 결정 과정(POMDP, Partially Observable Markov Decision Process)으로 모델링할 수 있다.

  • 상태 공간 S: 환경의 실제 상태 (완전히 관찰 불가능)
  • 행동 공간 A: 도구 호출 + 자연어 thought 생성
  • 관찰 공간 O: 도구 반환값, 환경 피드백
  • 정책 π: 언어 모델 자체 (θ로 파라미터화)

정책은 다음과 같이 정의된다:

π_θ(a_t | o_1, a_1, ..., o_{t-1}, a_{t-1}, o_t)

여기서 컨텍스트 윈도우가 사실상 에피소드 메모리 역할을 한다. Thought는 행동 공간에 속하지만 환경에 영향을 주지 않으므로 관찰값을 변경하지 않는다. 이 점에서 Thought는 내부 상태를 명시적으로 기록하는 "언어적 워킹 메모리"로 볼 수 있다.

프롬프트 구조 (Few-shot 예시):

Question: 콜로라도 조폐국 동쪽 섹터에 가장 가까운 도시는?

Thought 1: 콜로라도 조폐국 동쪽 섹터의 위치를 검색해야 한다.
Action 1: Search[Colorado State Mint eastern sector]
Observation 1: 콜로라도 조폐국은 덴버에 위치하며...

Thought 2: 덴버의 동쪽에 있는 주요 도시를 확인해야 한다.
Action 2: Search[cities east of Denver Colorado]
Observation 2: 오로라(Aurora)가 덴버 동쪽에 위치한다.

Thought 3: 답은 오로라다.
Action 3: Finish[Aurora]

성능 및 비교

논문에서 세 가지 벤치마크에 걸쳐 네 가지 방법을 비교했다.

지식 집약적 추론 (HotpotQA, FEVER)

방법HotpotQA EMFEVER Acc
Standard prompting28.757.1
CoT only29.456.3
Act only25.758.9
ReAct35.164.3
ReAct + CoT-SC (best-of)40.769.6

HotpotQA에서 ReAct는 CoT 대비 약 5.7 EM 포인트 개선을 보였다. FEVER에서는 Act only보다 높은 정확도를 달성하면서도 CoT의 추론 능력을 유지했다.

의사결정 벤치마크 (AlfWorld, WebShop)

방법AlfWorld 성공률WebShop 점수
BUTLER (IL+RL)22%-
Act only45%33.4
ReAct71%40.2

AlfWorld는 텍스트 기반 가상 환경에서 가구 조작 등의 태스크를 수행하는 벤치마크다. ReAct는 모방학습+강화학습 조합인 BUTLER보다 약 3배 높은 성공률을 기록했다. 이는 명시적 추론 트레이스가 희소 보상 환경에서 특히 효과적임을 보여준다.

CoT vs Act vs ReAct 오류 분석:

  • CoT 전용: 환각(hallucination) 비율 높음. 사실 검증 불가로 잘못된 전제 위에 추론 누적
  • Act 전용: 추론 흔적 없이 행동만 반복. 왜 이 행동을 하는지 모델 자체가 맥락을 잃음
  • ReAct: 두 오류 모두 감소. 하지만 추론 루프가 길어질수록 비용 증가

장점과 한계

장점

  1. 해석 가능성(interpretability): Thought 트레이스가 그대로 남으므로 모델이 왜 특정 도구를 호출했는지 추적 가능하다. 디버깅과 감사(audit)가 용이하다.

  2. 동적 지식 접근: 학습 데이터 컷오프를 넘어선 실시간 정보에 접근 가능하다. 검색, 계산, 코드 실행 등 다양한 도구와 결합할 수 있다.

  3. 오류 복구 능력: 관찰 결과가 예상과 다르면 Thought 단계에서 전략을 수정할 수 있다. 단순 Act 루프는 이 자기 수정 기능이 없다.

  4. Few-shot 적용: 별도의 파인튜닝 없이 몇 개의 예시 프롬프트만으로 동작한다. 모델 가중치를 건드리지 않아 배포 비용이 낮다.

한계

  1. 무한 루프 위험: 도구가 원하는 정보를 반환하지 않거나 모델이 같은 쿼리를 반복할 때 루프를 탈출하지 못한다. 별도의 최대 스텝 수 제한이 필수다.

  2. 도구 선택 오류 (tool hallucination): 존재하지 않는 도구를 호출하거나, 올바른 도구를 잘못된 인자로 호출하는 경우가 있다. 도구 명세(spec)를 프롬프트에 명확히 정의해야 한다.

  3. 컨텍스트 누적 비용: 스텝이 늘어날수록 Thought/Action/Observation이 쌓여 입력 토큰이 기하급수적으로 증가한다. 긴 에피소드에서는 비용과 지연(latency) 문제가 심각해진다.

  4. 추론 품질 의존성: Thought의 질이 낮으면 의미 없는 행동을 계속 반복한다. 모델 자체의 추론 능력이 ReAct 성능의 상한선이다.

  5. 병렬 처리 불가: 기본 ReAct는 순차적 루프이므로 여러 도구를 동시에 호출할 수 없다. 독립적인 정보 수집을 병렬화하려면 별도 설계가 필요하다.

실무 적용 가이드

LangChain에서의 구현

LangChain은 create_react_agent 함수로 ReAct 에이전트를 제공한다:

python
from langchain import hub
from langchain.agents import create_react_agent, AgentExecutor
from langchain_community.tools import DuckDuckGoSearchRun

tools = [DuckDuckGoSearchRun()]
prompt = hub.pull("hwchase17/react")  # ReAct 표준 프롬프트

agent = create_react_agent(llm, tools, prompt)
executor = AgentExecutor(
    agent=agent,
    tools=tools,
    max_iterations=10,          # 무한 루프 방지
    handle_parsing_errors=True,  # 도구 호출 오류 복구
    verbose=True
)

result = executor.invoke({"input": "2025년 노벨 물리학상 수상자는 누구인가?"})

LlamaIndex에서의 구현

LlamaIndex는 ReActAgent를 내장 제공한다:

python
from llama_index.core.agent import ReActAgent
from llama_index.core.tools import FunctionTool

def search_web(query: str) -> str:
    """웹에서 정보를 검색한다."""
    ...

agent = ReActAgent.from_tools(
    [FunctionTool.from_defaults(fn=search_web)],
    max_iterations=15,
    verbose=True
)
response = agent.chat("최신 AI 모델 벤치마크 결과를 알려줘")

Claude의 tool_use와 ReAct의 관계

@Claude Code를 포함해 Anthropic의 Claude API가 제공하는 tool_use 메시지 타입은 구조적으로 ReAct 패턴과 동일하다. Claude의 <thinking> 블록이 Thought에 해당하고, tool_use 컨텐츠 블록이 Action에, tool_result 블록이 Observation에 대응한다. 차이는 Thought가 별도 텍스트가 아닌 내부 추론(extended thinking)으로 처리된다는 점이다. @Extended Thinking 기능 활성화 시 이 Thought 과정이 명시적으로 노출된다.

@Agentic Workflow와의 관계

ReAct는 단일 에이전트 루프의 핵심 패턴이고, Agentic Workflow는 여러 ReAct 에이전트를 조합해 복잡한 파이프라인을 구성하는 상위 개념이다. 오케스트레이터-서브에이전트 구조에서 각 서브에이전트는 내부적으로 ReAct 루프로 동작한다.

프로덕션 배포 시 체크리스트:

  • 최대 반복 횟수(max_iterations) 설정: 도구 유형에 따라 보통 5~15 사이
  • 타임아웃 설정: 단일 도구 호출당 시간 제한 필수
  • 도구 명세 명확화: 각 도구의 이름, 설명, 입력 스키마를 구체적으로 작성
  • 오류 처리: 도구 실패 시 재시도 또는 대안 도구로 폴백하는 로직
  • 비용 모니터링: 에피소드당 평균 토큰 사용량 추적

ReAct의 발전형:

  • Reflexion (Shinn et al., 2023): 에피소드 종료 후 실패를 언어로 반성(reflection)하여 다음 에피소드에 반영한다. ReAct가 에피소드 내 자기 수정이라면 Reflexion은 에피소드 간 자기 개선이다.

  • LATS (Language Agent Tree Search) (Zhou et al., 2023): ReAct를 트리 탐색과 결합한다. 각 Thought/Action 선택지를 트리 노드로 확장하고 MCTS(Monte Carlo Tree Search) 방식으로 탐색한다. 단일 경로 실패에 취약한 ReAct의 한계를 극복한다.

  • Tree of Thoughts (Yao et al., 2023): 단일 추론 경로 대신 여러 Thought를 동시에 생성하고 BFS/DFS로 탐색한다. 수학 문제, 창의적 글쓰기 등 탐색이 필요한 태스크에서 유리하다.

  • ReWOO (Xu et al., 2023): 도구 호출 전에 전체 계획을 먼저 수립한다(Plan-then-Execute). 불필요한 도구 호출을 줄여 토큰 비용을 절감한다.

Footnotes

  1. Yao, S., Zhao, J., Yu, D., Du, N., Shafran, I., Narasimhan, K., & Cao, Y. (2022). ReAct: Synergizing Reasoning and Acting in Language Models. ICLR 2023. arXiv:2210.03629. ↩

참고 자료

ReAct: Synergizing Reasoning and Acting in Language Models
arXiv.org

ReAct: Synergizing Reasoning and Acting in Language Models

While large language models (LLMs) have demonstrated impressive capabilities across tasks in language understanding and interactive decision making, their abilities for reasoning (e.g. chain-of-thought prompting) and acting (e.g. action plan generation) have primarily been studied as separate topics. In this paper, we explore the use of LLMs to generate both reasoning traces and task-specific actions in an interleaved manner, allowing for greater synergy between the two: reasoning traces help the model induce, track, and update action plans as well as handle exceptions, while actions allow it to interface with external sources, such as knowledge bases or environments, to gather additional information. We apply our approach, named ReAct, to a diverse set of language and decision making tasks and demonstrate its effectiveness over state-of-the-art baselines, as well as improved human interpretability and trustworthiness over methods without reasoning or acting components. Concretely, on question answering (HotpotQA) and fact verification (Fever), ReAct overcomes issues of hallucination and error propagation prevalent in chain-of-thought reasoning by interacting with a simple Wikipedia API, and generates human-like task-solving trajectories that are more interpretable than baselines without reasoning traces. On two interactive decision making benchmarks (ALFWorld and WebShop), ReAct outperforms imitation and reinforcement learning methods by an absolute success rate of 34% and 10% respectively, while being prompted with only one or two in-context examples. Project site with code: https://react-lm.github.io

react-lm.github.io

react-lm.github.io

Reflexion: Language Agents with Verbal Reinforcement Learning
arXiv.org

Reflexion: Language Agents with Verbal Reinforcement Learning

Large language models (LLMs) have been increasingly used to interact with external environments (e.g., games, compilers, APIs) as goal-driven agents. However, it remains challenging for these language agents to quickly and efficiently learn from trial-and-error as traditional reinforcement learning methods require extensive training samples and expensive model fine-tuning. We propose Reflexion, a novel framework to reinforce language agents not by updating weights, but instead through linguistic feedback. Concretely, Reflexion agents verbally reflect on task feedback signals, then maintain their own reflective text in an episodic memory buffer to induce better decision-making in subsequent trials. Reflexion is flexible enough to incorporate various types (scalar values or free-form language) and sources (external or internally simulated) of feedback signals, and obtains significant improvements over a baseline agent across diverse tasks (sequential decision-making, coding, language reasoning). For example, Reflexion achieves a 91% pass@1 accuracy on the HumanEval coding benchmark, surpassing the previous state-of-the-art GPT-4 that achieves 80%. We also conduct ablation and analysis studies using different feedback signals, feedback incorporation methods, and agent types, and provide insights into how they affect performance.

Language Agent Tree Search Unifies Reasoning Acting and Planning in Language Models
arXiv.org

Language Agent Tree Search Unifies Reasoning Acting and Planning in Language Models

While language models (LMs) have shown potential across a range of decision-making tasks, their reliance on simple acting processes limits their broad deployment as autonomous agents. In this paper, we introduce Language Agent Tree Search (LATS) -- the first general framework that synergizes the capabilities of LMs in reasoning, acting, and planning. By leveraging the in-context learning ability of LMs, we integrate Monte Carlo Tree Search into LATS to enable LMs as agents, along with LM-powered value functions and self-reflections for proficient exploration and enhanced decision-making. A key feature of our approach is the incorporation of an environment for external feedback, which offers a more deliberate and adaptive problem-solving mechanism that surpasses the constraints of existing techniques. Our experimental evaluation across diverse domains, including programming, interactive question-answering (QA), web navigation, and math, validates the effectiveness and generality of LATS in decision-making while maintaining competitive or improved reasoning performance. Notably, LATS achieves state-of-the-art pass@1 accuracy (92.7%) for programming on HumanEval with GPT-4 and demonstrates gradient-free performance (average score of 75.9) comparable to gradient-based fine-tuning for web navigation on WebShop with GPT-3.5. Code can be found at https://github.com/lapisrocks/LanguageAgentTreeSearch

Tree of Thoughts: Deliberate Problem Solving with Large Language Models
arXiv.org

Tree of Thoughts: Deliberate Problem Solving with Large Language Models

Language models are increasingly being deployed for general problem solving across a wide range of tasks, but are still confined to token-level, left-to-right decision-making processes during inference. This means they can fall short in tasks that require exploration, strategic lookahead, or where initial decisions play a pivotal role. To surmount these challenges, we introduce a new framework for language model inference, Tree of Thoughts (ToT), which generalizes over the popular Chain of Thought approach to prompting language models, and enables exploration over coherent units of text (thoughts) that serve as intermediate steps toward problem solving. ToT allows LMs to perform deliberate decision making by considering multiple different reasoning paths and self-evaluating choices to decide the next course of action, as well as looking ahead or backtracking when necessary to make global choices. Our experiments show that ToT significantly enhances language models' problem-solving abilities on three novel tasks requiring non-trivial planning or search: Game of 24, Creative Writing, and Mini Crosswords. For instance, in Game of 24, while GPT-4 with chain-of-thought prompting only solved 4% of tasks, our method achieved a success rate of 74%. Code repo with all prompts: https://github.com/princeton-nlp/tree-of-thought-llm.

LangChain overview - Docs by LangChain
Docs by LangChain

LangChain overview - Docs by LangChain

LangChain is an open source framework with a prebuilt agent architecture and integrations for any model or tool—so you can build agents that adapt as fast as the ecosystem evolves

ReActAgent - A Simple Intro with Calculator Tools
LlamaIndex OSS Documentation

ReActAgent - A Simple Intro with Calculator Tools

이전글

RAG (Retrieval-Augmented Generation)

다음글

RLHF (Reinforcement Learning from Human Feedback)

댓글

0개

댓글을 작성하려면

로그인

해주세요

방법론 정보

관련 게시글

1개

사용 서비스

1개

관련 게시글

Claude Code 내부 동작 방식 완전 해부 — 에이전틱 루프부터 컨텍스트 로딩까지

DEEP_DIVE

사용 서비스

Claude Code