Skip to content
Naveen Raj

Building AI Agents from Scratch with Python · Foundations

What Is an Agent, Really?

An agent, in the sense this guide uses the word, is a program that:

  1. Observes some state of the world (a user message, a file, an API response).
  2. Decides what to do next using a model, not a fixed script.
  3. Takes an action that changes the world (calls a tool, writes a file, sends a reply).
  4. Repeats, using the result of its own action as the next observation.

That's it. No agent framework, no buzzwords — just a loop with a model making the branching decisions instead of an if/else chain.

The model doesn't have to be an LLM. Historically, "agent" comes from reinforcement learning, where the decision-maker could be a Q-table. What's new in the last few years is using a language model as the decision-maker, because language models are good at picking actions described in natural language.

Why this definition matters

A lot of confusion in this space comes from calling three very different things "agents":

ThingHas a loop?Decides its own next step?Example
ChatbotNoNo — one request, one responseA support widget that answers FAQs
Workflow / pipelineYesNo — the sequence is fixed in codeA nightly ETL job with retries
AgentYesYes — the model picks the next actionA coding assistant that decides which file to open next

If the sequence of steps is fixed at write-time, you have a workflow, and you should keep it that way — it's easier to test, debug, and reason about. Reach for an agent only when the next step genuinely depends on what happened, in a way you can't enumerate in advance.