AI Agents Academy

Build your first agent, add memory, tools and planning to it, then run a team of agents and try the MCP protocol in a visual simulator that works without any API.

60hands-on lessons

Module 1 · Lesson 3 · 15 min read

Agent architecture and its components

Agent Architecture and Components

Introduction

Every intelligent agent, however simple, is made of cooperating components: environment, perception, reasoning, planning, memory, tools, action and feedback. In this lesson we break the agent down into these components and see how this breakdown helps with design and debugging.

Learning objectives

  • Name the eight components of agent architecture and the role of each
  • Link each component to a real example from a technical support agent
  • Use the architecture as a checklist for debugging an agent
  • Read a Python structure that separates perception, reasoning, action and memory

Why talk about "architecture"?

As an agent grows, it becomes hard to understand as a single piece. Thinking in separate components helps you locate the fault: is the problem that the agent did not perceive the information? Or that it perceived it and reasoned badly? Or that it reasoned well but the tool failed? The CoALA framework (Cognitive Architectures for Language Agents), published in 2023, proposes a structured way to describe language agents through memory modules, an action space and a decision-making procedure. Here we use a teaching breakdown close to it.

ObservationReasoning engineLLM / ReasonerInstructions and goalInstructions / GoalMemoryPlannerToolsTools / APIsEnvironmentSafety guardrailsGuardrails
The agent's components: a reasoning engine (usually a language model) governed by the instructions, connected to memory, tools and the planner, and surrounded by safety controls.

The eight components

1. Environment

Everything outside the agent that interacts with it: the user, files, databases, application programming interfaces (APIs), and even other agents. The environment may be fully observable or partially observable; an agent rarely sees everything.

2. Perception

Turning what comes from the environment into a form the agent understands. In a language agent this usually means turning tool results, PDF files and images into text or structured data that enters the context.

3. Reasoning

The heart that decides. In modern agents it is the language model that reads the goal and context and chooses what to do. The quality of reasoning depends on the model and on the quality of the instructions and context provided.

4. Planning

Breaking the big goal into steps. It may be explicit (a written task list) or implicit (the agent decides one step per cycle). We cover this in detail in the planning module.

5. Memory

What the agent keeps: the current conversation context (short term) and lasting information about the user or the domain (long term). The memory module is dedicated to this.

6. Tools

The functions the agent can call: search, a calculator, reading a file, querying a database. Tools are the agent's "hands".

7. Action

The actual execution of a decision: calling a tool, sending a message to the user, or handing the task to another agent.

8. Feedback

The result of the action returns to the agent as a new observation: success, an error, data. Without it the agent cannot correct its course.

A practical example: a technical support agent for the university lab

A student writes: "The printer in Lab 3 is not working." Let us map what happens onto the components:

ComponentWhat happens
EnvironmentThe lab ticketing system, the fault knowledge base, the student
PerceptionReading the message and extracting "Lab 3" and "printer"
MemoryRemembering that the same student reported a similar fault yesterday
PlanningSearch the known faults, then suggest a fix, and if it fails open a ticket
Toolsknowledge_search and task_manager
ActionCalling search, then opening a ticket
FeedbackThe ticket number or an error message from the system

The architecture in code

The following example puts the components together in one structure in pure Python. Reasoning here is simple rules to illustrate the idea; in a real agent a language model call takes their place.

python
from dataclasses import dataclass, field

KB = {"printer": "Restart the printer and check the paper",
      "wifi": "Sign in through the university portal"}

def knowledge_search(query):
    return next((v for k, v in KB.items() if k in query), None)

def open_ticket(text):
    return {"ticket_id": 1042, "text": text}

@dataclass
class Agent:
    tools: dict
    memory: list = field(default_factory=list)   # memory

    def perceive(self, raw):                       # perception
        return raw.lower()

    def reason(self, obs):                          # reasoning and planning
        if "printer" in obs and not any(m.get("tried_kb") for m in self.memory):
            return ("knowledge_search", obs)
        return ("open_ticket", obs)

    def act(self, decision):                        # action through tools
        name, arg = decision
        result = self.tools[name](arg)
        self.memory.append({"tool": name, "result": result,
                            "tried_kb": name == "knowledge_search"})
        return result                               # feedback

agent = Agent(tools={"knowledge_search": knowledge_search, "open_ticket": open_ticket})
obs = agent.perceive("Printer in lab 3 is not working")
print(agent.act(agent.reason(obs)))   # first attempt: the knowledge base
print(agent.act(agent.reason(obs)))   # second: open a ticket

Notice how memory affected the second decision: because the agent had already tried the knowledge base, it moved on to opening a ticket instead of repeating itself.

Summary

Agent architecture divides it into components: the environment it works in, perception that turns inputs into information, reasoning and planning that decide, memory that keeps context, tools and actions that execute, and feedback that closes the loop. The CoALA framework provides an academic basis for this breakdown. Thinking in components makes design clearer and makes debugging systematic instead of guesswork.

Terms

TermEnglishDefinition
EnvironmentEnvironmentEverything outside the agent that interacts with it: users, systems and data
ReasoningReasoningThe process of choosing the next action based on the goal and context
PlanningPlanningBreaking the goal into executable steps
MemoryMemoryThe information the agent keeps across steps or sessions
ToolToolAn external function the agent calls to perform an action or fetch information
Partially observablePartially ObservableAn environment whose full state the agent cannot see at any moment

Review questions

  1. What is the difference between perception and reasoning? Give an example of a fault in each.
  2. How did memory affect the technical support agent's second decision?
  3. Why is feedback necessary to close the loop?
  4. Design a components table for an agent that helps book study rooms.

References