No history yet

Agentic Reasoning Loops

The Thinking and Acting Cycle

A standard Large Language Model (LLM) takes a prompt and produces a single, static response. This is powerful for tasks like summarisation or translation, but it's a one-way street. The model can't interact with the world, test its assumptions, or adjust its approach based on new information.

An AI agent, by contrast, is dynamic. It operates within a loop, allowing it to reason, take action, and learn from the outcome. This cycle is what elevates an LLM from a passive text generator into an active problem-solver.

This "looping" capability—where the AI takes an action, observes the result, and takes another action—is what separates an agent from a chatbot.

The ReAct Pattern

The most fundamental agentic loop is the ReAct pattern, which stands for "Reason + Act." Instead of generating a final answer immediately, the model follows a strict, iterative process. It cycles through three distinct steps: Thought, Action, and Observation.

  1. Thought: The agent thinks privately about its goal and what it needs to do next. This is its internal monologue, where it strategises and breaks down the problem.
  2. Action: Based on its thought, the agent chooses a specific tool or function to execute. This could be searching the web, querying a database, or running a piece of code.
  3. Observation: The agent receives the result from its action. This new information feeds directly back into the loop, informing the next thought.

This cycle repeats until the agent has gathered enough information to confidently answer the user's original request. It’s a simple but incredibly effective way to solve complex problems that require multiple steps and access to external information.

Consider an agent tasked with finding the current CEO of Microsoft and their alma mater. A single LLM call might fail if its training data is outdated. A ReAct agent would tackle it like this:

StepContent
ThoughtI need to find the current CEO of Microsoft. I will use the search tool.
Actionsearch('current CEO of Microsoft')
ObservationThe search result says Satya Nadella is the current CEO of Microsoft.
ThoughtNow I know the CEO is Satya Nadella. I need to find his alma mater. I will use the search tool again.
Actionsearch('Satya Nadella alma mater')
ObservationSearch results indicate Satya Nadella received a degree from the University of Wisconsin–Milwaukee.
ThoughtI have found both the CEO's name and their alma mater. I have enough information to answer the user's query.
Actionfinish('The current CEO of Microsoft is Satya Nadella, who attended the University of Wisconsin–Milwaukee.')

Advanced Reasoning Patterns

The basic ReAct loop is a powerful starting point, but more complex tasks require more sophisticated reasoning. Two key patterns build on this foundation: Reflection and Plan-and-Execute.

Reflection: The Power of Self-Correction

The [{}] pattern introduces a step for self-critique. After an agent generates an initial response or completes a step, it pauses to evaluate its own work. It asks questions like: "Is this answer accurate?", "Is it complete?", or "Could this be improved?"

This is often implemented by using a second LLM call with a prompt designed to act as a critic. The critic reviews the initial output and provides feedback. The original agent then takes this feedback and refines its answer. This process helps agents catch their own mistakes, improve the quality of their work, and avoid jumping to premature conclusions.

This iterative refinement is crucial for tasks demanding high accuracy, like writing code or drafting legal documents.

Plan-and-Execute: Strategy First

For long or multi-faceted tasks, a simple ReAct loop can get lost. The [{}] architecture addresses this by separating high-level planning from low-level execution.

First, a 'Planner' agent creates a detailed, step-by-step plan to achieve the overall goal. It doesn't execute anything; it only thinks and outlines the strategy. Then, an 'Executor' agent takes this plan and carries out each step, one by one, using the necessary tools. The executor focuses only on the immediate task given by the plan. This division of labour makes the agent's process more robust and easier to debug. If something goes wrong, you can see whether the fault was in the initial plan or in the execution of a specific step.

These patterns aren't mutually exclusive. A sophisticated agent might first create a plan, then use a ReAct loop with reflection to execute each step of that plan, combining strategy with iterative, self-correcting action.

Time to check what you've learned.

Quiz Questions 1/5

What is the primary characteristic that distinguishes an AI agent from a standard Large Language Model (LLM)?

Quiz Questions 2/5

What does the acronym ReAct stand for in the context of AI agents?

By understanding these reasoning loops, you can build agents that go beyond simple Q&A to perform complex, multi-step tasks with greater reliability and intelligence.