AI agents and agentic AI
An AI agent is a program in which a language model decides the next step: it asks for tools, reads their results and repeats until the task is done. Agentic AI is the larger system in which several agents split a goal, share their work and adapt as they go.
A chat model turns text into text. It can describe a shop's delivery policy in general terms, but it can't look up order 1042, and it can't issue a refund. Most applications worth building need both, so developers give the model tools, functions it can ask the application to run, and a loop that feeds each result back until the task is done: an AI agent. When several agents divide a larger goal between them, pass on what they find and check one another's work, the system as a whole is called agentic AI. Both terms are used loosely, so this lesson pins them down, shows the loop every agent runs, and adds the question behind most design decisions: how much of the control flow should the model own? The modules that follow build the answers, from fixed chains to agents with tools to graphs of cooperating steps.
What an agent adds to a model
The chatbot of lesson 7.3 can talk but not act: it knows its training data and the conversation, nothing more. An agent puts the model inside a program with four more parts:
| Part | What it does | In an order-support agent |
|---|---|---|
| Model | Reads everything sent so far and decides the next step: answer, or call a tool with arguments. Often called the agent's brain | A chat model |
| Instructions | The system prompt: role, goal, rules, and when to use which tool | "You are a support assistant. Look orders up before answering." |
| Tools | Functions the model may ask the application to run, each described to it by a name, a description and a JSON schema of its arguments (lesson 4.3) | get_order(order_id) over the orders database, search_policy(topic) over the shop's policies |
| Memory | What the agent keeps: the messages of the current task (short-term, lesson 7.3) and facts kept across conversations (long-term, lesson 11.5) | This conversation; the customer's past orders |
| Loop | The application code that calls the model, runs the tools it asks for, sends back the results and decides when to stop | About ten lines, below |
The model never runs a tool itself. It returns a tool call, a structured request that names a tool and its arguments, and the application decides what happens next: it can check the arguments, refuse, ask a person, or run the function and send the result back as a new message. Every action passes through that code, so the application, not the model, is where permissions, limits and logs belong.
The agent loop
Every agent, from a support bot to a coding assistant, repeats one cycle: the model reads the messages and picks a step, the application carries it out, and the result joins the messages for the next turn. Here is one customer's question, turn by turn:
One request through an agent
Press Play or step with Next. A support agent with two tools answers one customer. The messages are the ones the first practice task below prints, where a script plays the model.
messages = [system_message, user_message] # perceive
for step in range(max_steps):
reply = model.invoke(messages) # reason
messages.append(reply)
if not reply.tool_calls: # an answer: stop
break
for call in reply.tool_calls: # act
result = tools[call["name"]](**call["args"])
messages.append(tool_message(call, result)) # observe
memory.save(messages) # learn
Ready
Observe: the model chose both tools and when to stop; the application only ran what it asked for, inside a step limit. A workflow would fix those steps in code.
Each turn has the four parts that describe any agent:
| Capability | Meaning | In an LLM agent |
|---|---|---|
| Perception | Gather data from the surroundings | Whatever enters the model's context: the user's message, tool results, retrieved documents, readings from sensors or APIs |
| Reasoning | Understand what is going on and decide | One model call: answer now, or call which tool with which arguments |
| Action | Do something specific | A tool call the application runs: a query, an API request, a file edit, a payment |
| Learning | Improve and adapt over time | Memory and feedback, kept outside the model |
Learning is the part most often oversold. The model's weights don't change while an agent runs. A deployed agent improves because it keeps memory (the conversation, facts about a user, notes from earlier tasks) and because people turn its runs and ratings into better prompts, better tools and test cases; occasionally a model is fine-tuned offline on that data VERIFY.
When the loop stops
The loop ends when the model answers instead of asking for a tool. Nothing forces a model to get there, so real agents add their own stops: a maximum number of steps, a token or cost budget, a time limit, and a person who can pause the run (lesson 14.3). LangGraph, which LangChain's agents run on, ends a run that goes past its recursion_limit with a GraphRecursionError. Its default allows thousands of steps (10,007 in version 1.2), so set a lower limit for agents that call paid models.
AI agents and agentic AI
The two terms describe different scopes.
An AI agent is an individual program built for a specific task, with some autonomy inside it. A customer-service chatbot that answers common questions and looks up orders is one; so is a banking bot that handles balance inquiries and transfers. Its processes are clearly defined: the goal, the tools and the allowed actions are fixed in advance, and the model only chooses among them.
Agentic AI describes a whole system in which several agents, each with its own role, work toward a larger goal. They split the goal into tasks, pass results to one another, check each other's work and change the plan when something happens at run time. The focus moves from one agent's answer to the behaviour of the system.
| AI agent | Agentic AI | |
|---|---|---|
| Scope | One specific task | A larger goal made of many tasks |
| Structure | A single agent with a focused purpose | Several agents plus the code that coordinates them |
| Autonomy | Limited: picks tools within a fixed process | Higher: plans, splits and re-plans the work |
| Decisions | Within predefined rules and actions | From real-time data and circumstances, so the path differs from run to run |
| Memory | The current task or conversation | State shared by the agents, often kept across tasks |
| Adapting | Changes when its developers change it | Adjusts its plan to results and feedback while it runs |
| Typical uses | Support chat, scheduling, summaries, routine transactions | Software delivery, research, coordinating devices, decision support |
| Main risks | A wrong answer or a wrong tool call | Errors that compound across agents, runaway cost, agents that contradict each other, harder testing |
| Example | Kind | Why |
|---|---|---|
| A customer-service chatbot that answers basic questions | AI agent | One task, a small set of answers and lookups |
| A banking bot for balance inquiries and transfers | AI agent | Clearly defined, auditable processes |
| A chatbot that hands order lookups to a retriever agent working on the order database | Agentic AI, in its smallest form | Two agents cooperate on one request |
| A smart home whose lights, thermostat and appliances share one goal: use less electricity | Agentic AI | Several systems coordinate from live data such as prices, occupancy and weather |
| A health assistant that combines a patient's history, real-time readings and lifestyle, and adapts to new research and the patient's feedback | Agentic AI | Many sources, an open-ended goal and a plan that changes over time; clinicians still decide |
Both are built from the same parts, a model that decides with tools and databases around it. They differ in how many agents there are, how much those agents may decide, and how they are coordinated.
Agent or tool?
In the order example, the retriever is an agent only if it decides something: rewriting the query, choosing which source to search, searching again when the results are poor. A retriever that runs one fixed query is a tool. The same component can be either, and turning it from one into the other is the step from basic RAG to agentic RAG (lesson 6.3, lesson 15.1).
Workflows, agents and levels of autonomy
Engineers usually draw the line by control flow rather than by the number of agents. Anthropic calls everything in this lesson an agentic system and separates two kinds: workflows, where models and tools follow paths fixed in code, and agents, where the model directs its own steps and tool use. LangChain defines an agent as a system that uses a model to decide the control flow, and describes autonomy as a scale, judged by three decisions: who decides a step's output, which step comes next, and which steps exist.
Who decides the next step
Six levels of autonomy and, at each, who makes three decisions: the output of a step, which step runs next, and which steps exist at all. Adapted from LangChain's levels of autonomy.
| Level | A step's output | The next step | The steps that exist | Modules | |
|---|---|---|---|---|---|
| Coderules and scripts, no model | code | code | code | - | |
| Workflows | One model callsummarise a support ticket | model | code | code | 06 |
| Chainretrieve, then answer | modelat every step | code | code | 06, 07 | |
| Routerbilling or technical support? | model | modelonce, no loops | code | 11, 13 | |
| Agents | Agentthe order agent: tools in a loop | model | modelin a loop, until it answers | codethe developer's tools | 09, 11 |
| Autonomous agentwrites and keeps its own tools | model | model | modelnew tools as it goes | - |
- Workflows: code fixes the path. The model writes each step's output and, in a router, picks one branch.
- Agents: the model picks the next step again and again, including when to stop. LangChain calls this level a state machine; the developer still decides which tools exist. Agents that write their own tools are mostly research, such as the Voyager paper's agent that learned skills in Minecraft.
- Several agents can sit on any row: a team of model calls that always runs in the same order is still a workflow.
Observe: down the table, each decision passes from code to the model. Each row buys flexibility with latency, cost and behaviour that is harder to test, and most production systems sit in the middle rows.