What Are AI Agents and How Do They Work?

Michael Murr··7 min read

Last updated: August 2026

An AI agent is a program where a large language model runs in a loop: it decides which tool to call, executes it, observes the result, and repeats until the task is done. A plain LLM call answers once and stops. An agent can search the web, read files, and run code on its own. In 2026, narrow single-purpose agents ship in production. Open-ended "do anything" agents mostly stay in demos.

The short version

  • An agent is an LLM in a loop, with tools, memory, and a goal. Decide, act, observe, repeat. That is the whole definition.
  • Reliability comes from constraint, not freedom. Narrow agents with three to six tools and a hard step limit work today; long-horizon autonomous agents do not.
  • You do not need machine learning to build one. Agent engineering is software engineering: tool design, prompt design, and error handling.

How is an AI agent different from a normal chatbot?

A chatbot is a conversation interface. You type, it replies, the exchange ends. An agent is a program that takes actions in the world. It reads a goal, asks the model what to do first, executes that step with a tool, feeds the result back, and asks again. The model is not just generating text, it is generating decisions and watching what happens.

Anthropic's engineering team draws a useful line in Building effective agents: a workflow follows a fixed, predetermined sequence of steps, while an agent decides the sequence itself. Most production systems marketed as agents in 2026 are actually workflows, and that is fine. Workflows are more predictable, and predictability is what real users want. The idea of interleaving reasoning with actions goes back to the ReAct paper by Yao et al. (2022), which showed that letting a model think and act in turns beat reasoning or acting alone. Every agent loop you will build is a descendant of that pattern.

If you have already shipped a retrieval app, agents are the natural next layer. If you have not, our walkthrough on what RAG is and building your first RAG app is the gentler on-ramp, because retrieval teaches the SDK basics without the extra moving parts.

What are the four parts of an agent?

Every agent, simple or complex, is built from the same four pieces. Learning them in this order is the fastest way to form a working mental model.

The model is the brain: it reads the current state of the task and outputs the next action. The tools are the hands: functions the agent can call, each defined with a name, a description, and an input schema, so the model can pick the right one. Memory is the notebook: the conversation history carries every prior step forward, and most beginner agents need nothing more persistent than that. The control loop is the operator: the code that reads the model's response, runs the chosen tool, appends the result, and asks again. That loop is the part you write, and writing it yourself once teaches more than any framework. If you are comfortable in Python already you can build this in a weekend; if not, our Python learning path gets you there first.

What works in production vs what only works in demos?

This is the section most beginner guides skip, so here is the honest read. The answer genuinely depends on how tightly you scope the agent, and the table below shows exactly what it depends on.

Agent typeShips in production?Why
Narrow agent, 3 to 6 toolsYesSmall decision space, easy to test, predictable cost
Agent that confirms irreversible actionsYesA human approves emails, deletes, and payments before they run
Agent with a hard step limit (15 to 25)YesCaps runaway loops and protects your API budget
"Do anything" autonomous agentDemo onlySearch space too large, reliability collapses on real tasks
Long-horizon agent (hours or days)Demo onlyMemory, error recovery, and cost predictability all break down
Multi-agent swarm of debatersMostly demoThe win over one well-prompted agent is usually small

The pattern is consistent. Narrow agents are real, useful, and shippable right now. Open-ended autonomous agents are a research direction, not a product category. Start narrow, add tools only when a concrete task forces you to, and always cap the iterations.

I saw this play out with a student who was given a Claude Code seat at his company to build an internal dashboard. Two parts of it were genuinely agentic: a step that turned natural-language questions into SQL, and a step that planned slide structure before rendering. We worked through the SQL piece together, and accuracy went from roughly 50% to nearly 100% once we structured the tool definitions properly. The lesson was not "use a bigger model," it was "constrain the job." If that workflow sounds familiar, our notes on Claude Code cover the same constrained-agent territory.

Frequently Asked Questions

Do I need to know machine learning to build an agent?

No. Agent engineering is software engineering, not ML research. You need solid Python, comfort with APIs, and a feel for how models respond to prompts. You do not need to train models, understand backpropagation, or know linear algebra. The hard parts (tool design, prompt design, error handling) are all software problems.

What is the difference between an agent and a RAG app?

RAG retrieves relevant documents and answers a single question with one model call. An agent runs in a loop and decides its own multi-step plan. They compose: you can give an agent a retrieval tool, or build a RAG system that uses no agent at all. Choose RAG when the task is one question over your documents, and an agent when the task has multiple steps or needs the model to decide what to do next.

Which framework should I learn first?

None. Build your first agent with no framework so you understand the loop. After that, pick based on the task: LangGraph is the popular general option, the Anthropic Agents SDK is the cleanest Claude-specific choice, and retrieval-heavy agents lean on LlamaIndex. The framework is the last decision, not the first.

Can an AI agent replace a junior employee in 2026?

For narrow, well-defined tasks, partially. For an end-to-end role, no. A support agent can clear Tier 1 tickets and escalate the rest; a research agent can draft a sourced report a human then edits. The teams getting real value scoped each agent to one job rather than building a general "AI worker."

How many tools should my first agent have?

Three to five. Start with web search and file read, add code execution if the task needs computation. Twenty tools means the model picks the wrong one half the time. A few carefully chosen tools beat a large pile of general ones every time.

Ready to build your first agent, not just read about one?

If you are serious about agents, the fastest path I know is working with someone who has taken 200+ adults from "what is an agent" to a shipped, portfolio-ready project. Book a free 15-minute Discovery Call: no pitch, just a plan for your situation.

Written by Michael Murr for AI Tutor Code: private 1-on-1 online tutoring for professionals learning Python, AI tools, Data Science, ML, and LLM engineering. 200+ students taught, 3,000+ hours delivered.

Related articles

Keep reading on related topics.

Enjoyed this article?

You can master this and more with a dedicated 1-on-1 tutor.

Book a Free Discovery Call