Understanding How AI Agents Plan, Act and Use Tools
This lesson explains how agents take foundation models beyond answering questions to completing tasks. They plan, call tools, observe the results and carry on until the goal is reached.
Learning outcomes
After completing this lesson, you will be able to:
- Describe the reason-and-act loop that an agent follows.
- Distinguish short-term from long-term agent memory.
- Distinguish the patterns for coordinating several agents.
- Explain what the Model Context Protocol (MCP) standardises.
How an agent works
An AI agent combines a foundation model (the reasoning engine) with tools, memory and a loop. Given a goal such as "rebook my cancelled flight", it repeats:
-
Plan
Decide the next step.
-
Call a tool
For example, search for flights or charge a card.
-
Observe
Read the result and decide what to do next.
This reason-and-act pattern is often called ReAct. Tools can be APIs, Lambda functions, databases, code execution, browsers or other agents. The model chooses a tool and its parameters through tool use (function calling), and the application runs it.
The following diagram shows the agent loop and the tools it can call.

Parts of an agent
Memory and context
An agent needs to remember information over two timescales. Short-term memory holds the current conversation and the steps the agent has taken in this task, so it can continue coherently. Long-term memory keeps facts and preferences across separate sessions, such as a customer's preferred seat, so the agent does not have to ask again next time. The following table summarises the two.
| Memory | Holds |
|---|---|
| Short-term | The current conversation and steps |
| Long-term | Facts and preferences across sessions, such as a preferred seat |
Context engineering decides what goes into the limited context window at each step: instructions, relevant memories, tool results and retrieved documents.
Short-term or long-term memory?
Multi-agent systems
Complex tasks can be split among several specialised agents, coordinated in one of three patterns. In the supervisor pattern, also called orchestrator, one agent receives the task, delegates parts of it to specialised sub-agents and combines their results. In the sequential pattern, agents hand work to each other in a fixed order, such as from a research agent to a writing agent to a reviewing agent. In the collaborative pattern, peer agents work together without a single leader. The following table summarises the patterns.
| Pattern | How it works |
|---|---|
| Supervisor (orchestrator) | Delegates to specialised sub-agents |
| Sequential | Hand-offs in a fixed order, for example from a research agent to a writer agent to a reviewer agent |
| Collaborative | Peers work together |
Workflow orchestration uses deterministic workflows for predictable processes and autonomous agents for open-ended ones.
Which multi-agent pattern?
Connecting agents to tools: MCP
The Model Context Protocol (MCP) is an open standard for connecting AI applications to tools and data. An MCP server exposes tools and resources, such as a CRM or file system, and any MCP-compatible agent can use them, replacing one-off integrations. Agent-to-agent (A2A) protocols let agents from different systems work together.
Connecting agents
Risks
Agents can take wrong or harmful actions if manipulated or if they misunderstand a request. Use least-privilege permissions, guardrails, human approval for high-impact actions, and full logging and tracing.
Watching an agent work through a task
A customer writes: "My flight to Lisbon tomorrow was cancelled. Please rebook me on the earliest flight and keep my aisle seat." An airline agent with access to three tools works through the reason-and-act loop:
| Step | Agent reasons | Tool call | Observation |
|---|---|---|---|
| 1 | I need the customer's booking | get_booking(customer_id) | Flight TP101 cancelled; seat 14C (aisle) |
| 2 | Find alternatives to Lisbon | search_flights("LIS", date) | TP103 at 09:10, TP105 at 14:30 |
| 3 | The earliest is TP103; check aisle seats | get_seats("TP103") | 12C and 20D free |
| 4 | Rebook with an aisle seat | rebook(booking, "TP103", "12C") | Confirmed |
| 5 | Done: reply to the customer | — | "You are on TP103 at 09:10, seat 12C." |
Long-term memory supplied the fact that this customer always prefers aisle seats. The rebooking tool can change only this customer's booking (least privilege), and a rebooking that cost extra money would require the customer's approval, keeping a human in the loop for high-impact actions.
What is the Model Context Protocol (MCP)?
Show answer
An open standard for connecting AI applications and agents to tools and data sources through MCP servers, so the same tools can be reused by different agents.
Exam Tips
Remember for the exam
- An agent combines a model, tools, memory and a planning loop.
- When the model decides which function to call, that is tool use (function calling).
- The standard way to connect agents to tools and data is the Model Context Protocol (MCP).
- A supervisor agent delegating to specialists is multi-agent collaboration.
- Remembering user preferences across sessions requires long-term memory.
- High-impact actions by an agent should require human approval.