DS DevShelfHub Projects · AI tools
Tutorials / AI Agents / Core Components
AI Agents Beginner · 10 min read Page 4 of 10

Core Components of an AI Agent: LLM, Tools, Memory, and Planning

By DevShelfHub

Every agent is built from the same four building blocks: an LLM, tools, memory, and a planning mechanism. Here is what each one does.

Series progress4 / 10
AI agent core components — LLM, tools, memory, and planning

Four Building Blocks

No matter which framework you use — LangChain, CrewAI, AutoGen, or plain Python — every agent is assembled from the same four components. Change how any one of them works and you change what the agent can do.

🧠

LLM

The reasoning core

🔧

Tools

What the agent can do

💾

Memory

What the agent remembers

📋

Planning

How the agent decides

1. The LLM — the reasoning core

The large language model is the brain of the agent. It reads everything in the context window — the goal, tool results, conversation history — and decides what to do next.

What it does: Reasons about the current state, selects which tool to call, generates the final answer.

Common choices: GPT-4o, Claude 3.5 Sonnet, Gemini 1.5 Pro, Llama 3, Mistral — any model that supports function/tool calling.

What it is NOT: The LLM does not execute code, browse the web, or write files directly. It only decides to call a tool that does those things.

Rule of thumb: A more capable LLM usually makes a better agent — stronger reasoning leads to better planning and fewer wasted tool calls.

2. Tools — what the agent can do

Tools are functions the agent can call to interact with the outside world. They are the hands of the agent. Without tools, an agent can only generate text — with tools it can take real actions.

Tool type Examples What it enables
Search Tavily, Serper, Brave Search Look up real-time information
Code execution Python REPL, Jupyter kernel Run calculations, process data
File I/O Read, write, append files Persist and retrieve data
Browser Playwright, Selenium Navigate pages, click buttons, fill forms
APIs GitHub, Slack, email, databases Interact with external services

You can write any Python function and register it as a tool. The LLM is given the function's name and description and decides when to call it.

3. Memory — what the agent remembers

Memory determines what information the agent can access as it works. There are two kinds:

Short-term memory (context window)

Everything in the current conversation — goals, tool results, prior reasoning steps. Limited by the model's context window (4k to 1M tokens depending on the model). When the window fills up, older information is lost unless summarised.

Long-term memory (external store)

A database outside the model — a vector store, a SQL database, or even a simple text file. The agent can read from and write to it during a run, or between separate runs. Enables the agent to "remember" facts across conversations.

In practice: Most beginner agents only use short-term memory. Long-term memory (via vector databases like ChromaDB or Pinecone) is added when the agent needs to recall information beyond a single session.

4. Planning — how the agent decides

Planning is the strategy the agent uses to figure out what to do next. There are two main approaches:

ReAct (Reason + Act)

The most common pattern. The agent alternates between reasoning steps ("I need to search for X") and action steps ("call search tool"). It writes its reasoning out as text before each action.

Good for: most tasks. Simple and transparent.

Plan-and-Execute

The agent first creates a complete plan (a list of steps), then executes each step. Useful for complex tasks with many dependencies.

Good for: long, structured tasks. More predictable.

How the four components work together

Understanding each component in isolation is useful, but agents only work when all four components interact in a tight loop. Here is how a single iteration flows through all four:

1

Memory loads context. The agent's short-term memory (the message list) is assembled — the system prompt, conversation history, and any prior tool results. If long-term memory is configured, relevant facts are retrieved and injected.

2

LLM reasons and plans. The full context is sent to the LLM along with tool descriptions. The model reads everything, reasons about what to do next (the planning component), and outputs either a tool call or a final answer.

3

Tool executes the action. If the LLM requested a tool call, the runtime dispatches it — runs a search, executes code, writes a file. The tool's output becomes new data the agent can work with.

4

Memory updates. The tool call, its arguments, and the result are appended to the message list (short-term memory). Optionally, the agent stores important findings in long-term memory for future reference.

Then the loop repeats from step 1. Each iteration adds more information to memory, which the LLM uses to make better decisions. This is the agent loop you saw on the previous page — now you can see how each component plays its part in every cycle.

Practical tips for each component

LLM selection

For prototyping, start with GPT-4o or Claude Sonnet — they handle tool calling reliably and are fast enough for interactive development. Switch to a smaller model (GPT-4o-mini, Haiku) only after you have confirmed the agent works correctly. Cheaper models save cost but make more planning errors, which can increase total cost through wasted tool calls.

Tool design

Each tool should do one thing and return a plain-text result. Avoid tools that return raw JSON or nested objects — the LLM parses text better than structured data. Name tools clearly: search_web is better than query. Limit the total number of tools to under 10; beyond that, the LLM starts making worse tool-selection decisions.

Memory management

For most beginner agents, short-term memory (the message list) is enough. When the conversation gets long, summarise older tool results instead of keeping the full text. For agents that run across multiple sessions, add a vector store (ChromaDB or Pinecone) to persist key facts and retrieve them at the start of each run.

Planning approach

Start with ReAct — it works for 80% of use cases and is the easiest to debug. Move to plan-and-execute only when the agent consistently fails because it does not look ahead. Adding "think step-by-step" to the system prompt often gets you most of the benefit of explicit planning without the added complexity.

AI Agent Components FAQ

What are the four components of an AI agent?

Every AI agent is built from four components: an LLM (the reasoning core), tools (functions the agent can call), memory (short-term context and long-term storage), and a planning mechanism (how the agent decides what to do next).

What does the LLM do in an AI agent?

The LLM is the brain of the agent. It reads the context window — goals, tool results, and conversation history — and decides what to do next. It does not execute code or browse the web directly; it decides which tool to call.

What is the difference between short-term and long-term memory in AI agents?

Short-term memory is everything in the current conversation context window, limited by the model's token capacity. Long-term memory uses an external store like a vector database to persist information across sessions.

What is the ReAct pattern in AI agents?

ReAct (Reason + Act) is the most common planning pattern. The agent alternates between reasoning steps and action steps, writing its reasoning as text before each action. It is simple, transparent, and works well for most tasks.

What are tools in an AI agent?

Tools are functions the agent can call to interact with the outside world — web search, code execution, file I/O, browser automation, or API calls. Without tools, an agent can only generate text.

Now that you understand the building blocks, see them in action on the how AI agents work page. When you are ready to choose a framework, the agent frameworks comparison covers LangChain, CrewAI, and more.

Quick summary

  • Every agent needs four things: an LLM, tools, memory, and a planning approach
  • The LLM reasons and decides; tools execute actions in the real world
  • Short-term memory lives in the context window; long-term memory uses an external store
  • ReAct is the most common planning pattern — reason, then act, then repeat