Course navigation
AgentsLesson 1 of 9

What are Agents?

You finished a RAG chatbot that retrieves on every message. An agent is the next step: you hand the model a few Python functions and let it decide when to call them. No code in this lesson yet.

Chains do not choose

A chain runs the same steps in the same order. Load, split, embed, retrieve, answer — you wired that path in End-to-End RAG and it does not change per question.

An agent leaves room to branch. You still call the model, but you also pass a short list of tools. The model can reply immediately, call one tool, or call a few and come back. You are not writing if weather then … in your script.

Your RAG chatbot today

question in
retriever
model
answer out

An agent

question in
model picks: reply or tool?
↓ if needed
tool (weather, math, HTTP, …)
answer out
Same RAG chatbot on the left — retrieve every time. On the right the model can skip retrieval or call something else.

Retrieval is not always enough

"What does the <a> tag do?" fits your existing retriever — the chunks already mention hyperlinks. "What's the weather in Kolkata?" does not. No PDF you indexed yesterday knows today's temperature. You need a live API, or the bot should admit it cannot tell.

same helper, different question
What's the weather in Kolkata today?
get_weather("Kolkata") → 34°C, humid
A
About 34°C and humid in Kolkata right now.
Nothing in your HTML notes file covers live weather. The model calls a weather function, reads the result, then answers.

Words you will see in docs

The rest of this module uses the same three terms over and over:

Model — same ChatOpenAI call as before; it now also decides whether to invoke a tool.

Tools — plain Python functions you register, e.g. fetch weather, run 2 + 2, hit a REST URL.

Loop — model → optional tool → model again until it stops with a final string.

LangChain bundles that loop in create_agent. We start wiring tools in the next lessons. Agent docs.

What's Next

Concept done. Next: Agent Types.