Skip to main content

Module 5: LLM Agents

An LLM prompted to answer a question is a calculator. An LLM given tools, memory, and the ability to take actions is an agent - a system that can observe its environment, reason about what to do next, and execute multi-step plans toward a goal.

This module takes you from first principles (what is a tool call?) through production-grade concerns (how do you safely deploy an agent that can execute code and send emails?). By the end, you will understand not just how agents work, but when they are the right tool and when they are not.


The Agent Loop

Every LLM agent, regardless of framework or complexity, runs some version of this loop:

The loop terminates when either the agent produces a final answer, reaches a maximum iteration limit, or encounters an unrecoverable error.


Module Map

#LessonCore Question
01Tool Use and Function CallingHow does an LLM call external functions?
02ReAct Agent PatternHow do we interleave reasoning and action?
03Planning and ReasoningHow do agents handle complex multi-step tasks?
04Memory SystemsHow do agents remember across turns and sessions?
05Multi-Agent ArchitecturesWhen and how do multiple agents collaborate?
06Agent EvaluationHow do we measure whether an agent actually works?
07LangChain Deep DiveWhat does LangChain actually do and when should you use it?
08LlamaIndex Deep DiveHow does LlamaIndex handle data-heavy agent applications?
09Agent Safety and GuardrailsHow do we prevent agents from doing harmful things?

Prerequisites

Before this module, you should be comfortable with:

  • Transformer architecture - attention, tokenization, context windows
  • Prompt engineering - system prompts, few-shot, chain-of-thought
  • API basics - calling LLMs via REST or SDK, handling responses
  • Python - async/await, dataclasses, basic type hints

Key Concepts Glossary

TermDefinition
AgentAn LLM system that can take actions, observe results, and iterate toward a goal
ToolAn external function the LLM can invoke (search, calculator, API, code runner)
ReActReasoning + Acting - the pattern of interleaving thought traces with tool calls
OrchestratorAn agent that coordinates other agents or tools
Context windowThe finite token budget available in a single LLM call
Episodic memoryStored records of past interactions, retrieved when relevant
Function callingThe API mechanism for getting structured JSON tool invocations from an LLM
GuardrailsSafety checks on agent inputs and outputs
TrajectoryThe full sequence of thoughts, actions, and observations in one agent run
HITLHuman-in-the-loop - requiring human approval for high-stakes actions

:::tip Where Agents Shine Agents are most powerful for tasks that are: (1) too long for a single prompt, (2) require external data or actions, (3) have multiple valid paths to the answer, or (4) require iteration and self-correction. :::

:::warning Where Agents Fail Agents are often the wrong choice for: simple Q&A, tasks that can be handled with one RAG retrieval, or anything where latency and cost predictability are critical. :::

© 2026 EngineersOfAI. All rights reserved.