Single Agent Patterns: Reason and Act Loop
Intent
Interleave explicit reasoning with environment actions so that each action is conditioned on an up-to-date interpretation of observations.
Introduction
In autonomous agent design, the core challenge is enabling large language models (LLMs) to interact with external environments dynamically while maintaining a goal-oriented plan. Traditional systems rely either on rigid, hard-coded execution graphs, or unconstrained model completions that fail to adapt to feedback. The Reason and Act (ReAct) Loop resolves this by integrating logical reasoning traces and concrete tools actions in a unified execution flow.
Structure of the Loop
The ReAct loop operates as a stateful cycle managed by an execution harness. The model generates a reasoning trace (a "thought") explaining its plan, followed by a structured action (a "tool call"). The harness intercept and executes this tool, collecting the result (the "observation"), and appends it back to the context window. The loop repeats until the model decides it has reached a terminal answer.
Originally introduced in the research paper ReAct: Synergizing Reasoning and Acting in Language Models [1], this pattern has become the foundational substrate of contemporary AI agents. Modern implementations have refined this pattern by replacing free-text action parsing with native function-calling interfaces. These interfaces enforce schema-constrained tool calls directly at the model output layer, yielding higher reliability and fewer parsing errors.
Trade-offs
While the ReAct loop provides robust, step-by-step problem-solving capabilities, it comes with important engineering and economic trade-offs:
Maximally Adaptive
Allows the agent to observe intermediate execution outcomes and dynamically adjust its path or recover from tools errors at each step.
Token Cost & Accumulation
The entire conversation history accumulates in the context window with each iteration, driving exponential token usage and higher cost.
Error Compounding
Minor hallucinations or incorrect tool observation parses in early steps compound across subsequent loop runs, leading to drift.
Infinite Wandering
Without strict loop-detection schemas, step budgets, and deterministic stop conditions, agents can enter infinite loops or wander endlessly.
Known Uses
The Reason and Act pattern forms the backbone of several major agent frameworks and benchmarks:
- ReAct Framework: The initial experimental implementation combining chain-of-thought prompting with tool interaction.
- AutoGPT: A pioneering open-source project showcasing unconstrained loops for multi-step agent actions.
- Production Coding Agents: Sophisticated agents evaluated on benchmarks like SWE-bench [3], where they construct reasoning paths to locate, edit, and verify bug fixes in large software codebases.
References
-
[1]
Yao, S., Zhao, J., Yu, D., Du, N., Shafran, I., Narasimhan, K., & Cao, Y. (2023). ReAct: Synergizing Reasoning and Acting in Language Models. International Conference on Learning Representations (ICLR).
https://arxiv.org/abs/2210.03629 -
[2]
Significant Gravitas. (2023). AutoGPT: An Empirical Demonstration of GPT-4 Accessing Internet and Local Tools.
https://github.com/Significant-Gravitas/AutoGPT -
[3]
Jimenez, C. E., Yang, J., Wetzel, A., Liang, B., Yao, S., Ruan, K., ... & Narasimhan, K. (2024). SWE-bench: Can Language Models Resolve Real-World GitHub Issues? International Conference on Learning Representations (ICLR).
https://arxiv.org/abs/2310.06770