Back to Blog
Agents7 min readJuly 18, 2024

AI Agents Explained

Understand planning, tool use, memory, reasoning loops, reflection, and multi-agent systems.

AI Agents Explained: Planning, Memory, Tools & Multi-Agent Systems

A standard chatbot answers one question at a time. Ask it to "book me a flight to Tokyo, reserve a quiet hotel near a train station, and draft an itinerary based on my preferences," and it runs into a wall — that's a multi-step task, not a single exchange, and a plain chatbot has no way to execute it. An AI agent is built for exactly this kind of request: it's an LLM paired with a way to act, a way to remember, and a way to plan, so that instead of just responding to a prompt, it works toward a goal through reasoning and real tool use.

1. The core architecture of an agent

The LLM functions as the agent's reasoning engine, but turning that into something that can actually get work done requires three additional capabilities layered on top.

               +-----------------------+
               |     LLM Brain         |
               | (Reasoning & Choice)  |
               +-----------+-----------+
                           |
        +------------------+------------------+
        |                  |                  |
+-------v-------+  +-------v-------+  +-------v-------+
|   Planning    |  |    Memory     |  |     Tools     |
| (Sub-goals,   |  | (Short-term,  |  | (APIs, Web,   |
| Self-reflection)| | Long-term DB) |  | Code Execution)|
+---------------+  +---------------+  +---------------+

Planning. Given a large objective, the agent uses chain-of-thought reasoning to break it into smaller sub-tasks — booking a flight, for instance, decomposes into searching airlines, comparing prices, checking the budget, and then calling a booking API. When something goes wrong along the way, such as a failed API call or a bad result, the agent can pause, assess what happened, and try a different approach instead of simply stopping.

Memory. Short-term memory is the ongoing conversation itself — what was said a couple of minutes ago, still available. Long-term memory works differently: past interactions, stated preferences, and document history get stored in a vector database, which is what allows the agent to recognize a returning user across separate sessions.

Tools. An agent without tools can only talk; with tools, it can act. These are external APIs or scripts it can call on — a web search API, a calculator or Python interpreter, a database lookup, or triggers into third-party software like Zapier, Slack, or email.

2. The ReAct loop: reason, then act

Agent execution generally runs on a loop called ReAct, short for reasoning and acting. The agent thinks through what to do next, picks a tool and sends it an input, reads back whatever the tool returns, and repeats that cycle until the goal is met.

3. Multi-agent systems

A single agent handling a genuinely complex workflow tends to get overloaded, which is why more involved tasks are often split across a team of specialized agents instead — not unlike how a magazine gets produced by people with different jobs.

Agent RoleSpecialtyResponsibilities
ResearcherFact-findingSearches the web, pulls data, compiles raw facts
WriterContent creationTurns raw research into a cohesive draft
EditorQuality controlChecks the draft for errors, sends revisions back to the writer
ManagerCoordinationDelegates tasks and tracks progress

Splitting the work this way means each agent runs on a prompt tailored specifically to its job, which tends to produce better output with fewer errors than asking one agent to do everything at once.

4. A ReAct loop in Python

This prototype shows an agent reasoning its way to a tool call — in this case, a calculator — to solve a problem it wouldn't handle reliably on its own:

import json

class=class="text-emerald-600 dark:text-emerald-400 font-semibold">"text-slate-400 dark:text-slate-500 italic"># 1. Define a mock tool (calculator)
def calculate(expression: str) -> str:
    try:
        return str(eval(expression))
    except Exception as e:
        return fclass="text-emerald-600 dark:text-emerald-400 font-semibold">"Error: {e}"

class=class="text-emerald-600 dark:text-emerald-400 font-semibold">"text-slate-400 dark:text-slate-500 italic"># 2. Simulated agent decision-making loop
def simple_agent(user_goal: str):
    print(fclass="text-emerald-600 dark:text-emerald-400 font-semibold">"Goal: {user_goal}\n")

    class=class="text-emerald-600 dark:text-emerald-400 font-semibold">"text-slate-400 dark:text-slate-500 italic"># Step 1: Thought
    thought = class="text-emerald-600 dark:text-emerald-400 font-semibold">"I need to calculate the total price of 14 items at $29.99 each with 8% tax."
    print(fclass="text-emerald-600 dark:text-emerald-400 font-semibold">"[Thought] {thought}")

    class=class="text-emerald-600 dark:text-emerald-400 font-semibold">"text-slate-400 dark:text-slate-500 italic"># Step 2: Action selection
    action_tool = class="text-emerald-600 dark:text-emerald-400 font-semibold">"calculate"
    action_input = class="text-emerald-600 dark:text-emerald-400 font-semibold">"(14 * 29.99) * 1.08"
    print(fclass="text-emerald-600 dark:text-emerald-400 font-semibold">"[Action] Calling tool '{action_tool}' with input: {action_input}")

    class=class="text-emerald-600 dark:text-emerald-400 font-semibold">"text-slate-400 dark:text-slate-500 italic"># Step 3: Observation (executing tool)
    if action_tool == class="text-emerald-600 dark:text-emerald-400 font-semibold">"calculate":
        observation = calculate(action_input)

    print(fclass="text-emerald-600 dark:text-emerald-400 font-semibold">"[Observation] Tool returned: {observation}")

    class=class="text-emerald-600 dark:text-emerald-400 font-semibold">"text-slate-400 dark:text-slate-500 italic"># Final answer
    final_answer = fclass="text-emerald-600 dark:text-emerald-400 font-semibold">"The total price comes out to ${float(observation):.2f}."
    print(fclass="text-emerald-600 dark:text-emerald-400 font-semibold">"\n[Final Output] {final_answer}")

class=class="text-emerald-600 dark:text-emerald-400 font-semibold">"text-slate-400 dark:text-slate-500 italic"># Run the agent loop
simple_agent(class="text-emerald-600 dark:text-emerald-400 font-semibold">"Calculate 14 items at $29.99 each plus 8% tax")
Goal: Calculate 14 items at $29.99 each plus 8% tax

[Thought] I need to calculate the total price of 14 items at $29.99 each with 8% tax.
[Action] Calling tool 'calculate' with input: (14 * 29.99) * 1.08
[Observation] Tool returned: 453.4488

[Final Output] The total price comes out to $453.45.

The core idea

What separates an agent from a chatbot is the shift from answering to doing. Once planning, memory, and tools are layered onto an LLM's reasoning, it becomes possible to hand off a workflow rather than a single question — and to have several such agents, each with a narrower job, working through parts of it together.

#Agents#AI Systems#ReAct Framework#Autonomy
Explore More Articles