ReAct (Reasoning and Acting)
Definition
ReAct is a pattern for AI agents in which the model alternates between writing down its reasoning and taking an action, such as a search or a tool call, then reasons about what came back before the next step. It is the loop behind many agents that use tools.
The loop
- ThoughtThe model notes what it knows and what it needs next.
- ActionIt calls a tool, such as a search or a database lookup.
- ObservationThe tool's result is added to the conversation.
- Repeat or answerIt reasons about the result and acts again, or gives its final answer.
Example trace
- ThoughtI need the order’s status before I can say why it’s late.
- Action
get_order("1042") - ObservationStatus: held at customs in Lagos since Monday.
- ThoughtI should check how long customs holds usually take there.
- Action
search_help("customs hold Nigeria") - ObservationMost holds clear within 3 to 5 working days.
- AnswerYour order is held at customs in Lagos. Holds usually clear in 3 to 5 working days, so expect it by next Tuesday.