What is 𝗥𝗲𝗔𝗰𝘁 𝗔𝗴𝗲𝗻𝘁 pattern?
As with most of the Agentic System Design patterns, it is all about flow engineering - how you construct the initial prompt and how you route your system according to the outputs produced by the LLM.
ReAct stands for Reasoning and Action. This means that the Agent is prompted to do both, reason about the actions it should take next and is provided the tools that it can use to act on the plan in the real world. After the actions are taken, they are used to reason about the next steps.
The implementations can vary, but on a high level you will see:
𝟭. The initial prompt is very important and is something that you would spend time tuning, on a high level:
➡️ You ask the LLM to solve the provided user query.
➡️ Provide the Agent with the list of tools it can use.
➡️ Ask it to print out the Reasoning and results of the Actions taken while performing a step.
➡️ Provide a list of actions and produced results so far - you start with an empty list.
➡️ You prompt the agent to take no more than N reasoning loops.
𝟮. This is an optional step where you can analyse the reasoning, you either check if the User Query was solved already or you can do that in the initial prompt. Here is also where you can break out of the loop if exceeding max steps.
𝟯. Reasoning output will have the next tool to be used. You execute the tool call and get the results.
𝟰. Combine the reasoning and tool call result, update the Reasoning and Action history with the data and run the updated prompt through the LLM again.
𝟱. Repeat until either the User Query is answered or N steps are reached.
ℹ️ Similar types of architectures are used to implement fully autonomous agents and agentic systems. The goal is to go beyond just CoT reasoning and allow the agent to reason continuously on actions it is taking in the real world.
❗️ Be sure to limit the amount of tools you give to your ReAct Agents. To many and your agent will get confused (try to stay bellow 10, less than 5 is even better). If you have many tools, start splitting your Agentic system into multiple Agents/Tasks.
✅ From my experience, this pattern works well as part of a larger Agentic System but is limited standalone.
Learn how to work with ReAct pattern hands-on in my End-to-end AI Engineering Bootcamp. Next cohort kicking off on January 12th:
maven.com/swirl-ai/end-to-en…
🎁 Code NYRESOLUTION for 10% off.
Have you tried implementing the ReAct agent pattern in your applications? What were your main observations? Let’s discuss in the comment section 👇