ReAct Framework Prompt Builder

Build a Reason+Act (ReAct) prompt for tool-using LLM agents

Ad placeholder (leaderboard)

ReAct framework prompt builder

ReAct — short for Reasoning and Acting — is the dominant pattern for tool-using LLM agents. Rather than answering in one shot, the model alternates between thinking out loud and calling tools, grounding each step in real results. This builder assembles the system prompt that defines that loop: the turn format, the tools the agent may call, an iteration ceiling, and the signal that ends the loop with a final answer.

How it works

The generated prompt declares a strict turn structure: Thought (private reasoning), Action (a tool call written as tool_name[input]), and Observation (the result you feed back). The model repeats this cycle until it has enough to respond, at which point it emits Final Answer: in the format you chose. Your tool list is rendered as a name-and-description block so the model knows exactly what is callable and what each returns. The max iterations value is stated explicitly so the model knows to converge or report that it could not finish.

Tips and notes

  • Describe tool outputs, not just inputs. “search[query] → returns top 5 web snippets” tells the model how to use the Observation, which sharpens its next Thought.
  • Keep the tool set small. Three or four well-scoped tools outperform a dozen overlapping ones; the model picks more reliably from a short menu.
  • Match the loop in code. The prompt expects your runtime to detect an Action, run the tool, and inject the Observation. The cap and format only work if your harness honors them.
  • Use the final-answer format to parse results. A fixed Final Answer: prefix makes it trivial to extract the response programmatically.
Ad placeholder (rectangle)