Pebellslearn by building
0%
RoadmapsMatrixCoursesSandboxSign in
The Agent Loop  ›  Lesson

What Are AI Agents?

What are AI Agents? 12 minAn AI agent is a language model running in a loop that chooses actions, usually tool calls, toward a goal and feeds each result back into its next decision.

What Are AI Agents?

Ask a chatbot "Is there a sleeper train from Pune to Jaipur on Friday?" and it can only guess from what it learned in training. Ask Tripmate, and it searches today's timetable, reads the result, and answers from real data. The difference is not a smarter model. It is that Tripmate is an agent.

The rule

An agent is a model in a loop, choosing actions toward a goal.

Three parts make that sentence work:

  • A model — the language model that reads the situation and decides what to do next.
  • Actions — usually tools: functions the program lets the model request, such as search_trains or send_email. The model only asks for a tool; your code runs it and hands back the result.
  • A loop — the program keeps calling the model, running what it asks for, and feeding results back until the goal is met or a limit is hit.
goal → model decides → tool runs → result goes back → model decides → … → answer

A plain chatbot does one pass: text in, text out. A fixed script runs the same steps every time. An agent sits between them: the steps are chosen at run time by the model, based on what it has seen so far.

Agents show up wherever the path to an answer is not known in advance:

  • Personal assistants — reading a calendar, drafting emails, booking things.
  • Code generation — writing code, running tests, reading errors, fixing, repeating.
  • Data analysis — querying a database, charting the result, noticing an odd number, querying again.
  • Web research and scraping — searching, opening pages, following links, extracting facts.
  • Game characters — a non-player character that decides what to say and do from the game state.

The shortcut

To decide whether something is really an agent, ask one question: "Who picks the next step — the code or the model?" If the code always picks, it is a script or a pipeline. If the model picks from a set of actions, and the results feed back in, it is an agent.

Is it an agent?Step 1 of 3
  1. A summariser

    Code sends an article, the model returns a summary, done. The code picked every step: not an agent.

The trap is calling every product with a model inside an "agent". Agents are more flexible, but also slower, costlier and harder to test. If a fixed pipeline does the job, it is often the better design.

Drills

Answer fast — trust the rule.

quick drill

What turns a language model into an agent?

quick drill

When Tripmate "uses" search_trains, who actually runs the search?

quick drill

A program always calls a model to translate a message, then always posts it to Slack. What is it?

quick drill

Which task most needs an agent rather than a fixed script?

Remember

  • An agent is a model in a loop, choosing actions toward a goal.
  • Shortcut: "Who picks the next step — the code or the model?"
  • Trap: using an agent where a simple fixed pipeline would be cheaper and more reliable.

Practice — level up

0/1 solved

Write your answer, then compare it with a rubric and a model answer.

ExplainAgent or pipeline?

A team wants to build a tool that reads each support email, labels it as billing, bug or other, and files it in the right queue. Someone suggests building an agent. Explain whether this needs an agent or a fixed pipeline, using the difference between the two.