What is an AI agent?
📖 4 min readUpdated 2026-04-19
An AI agent is an LLM in a loop with tools. Give it a goal. It thinks. It picks a tool. It uses the tool. It reads the result. It thinks again. It repeats until the goal is done. That's the whole idea. Everything else (frameworks, memory systems, multi-agent orchestration) is scaffolding around this one loop. If you understand the loop, you understand agents.
Why this matters
A plain LLM call is a one-shot: you send a prompt, you get an answer, done. The model works with whatever context you crammed into the prompt. If it needs fresh information, it guesses. If it needs to take an action in the real world, it can't.
An agent breaks out of the one-shot. It can look things up. It can call APIs. It can check its own work. It can run until it actually finishes the task instead of producing a plausible-sounding sentence. That's the jump from "chatbot that sounds smart" to "system that gets things done."
The loop, drawn out
Four moving parts. Goal goes in. The LLM picks what to do. A tool runs. The result comes back. The LLM checks whether the goal is done. If not, it loops. That's the whole shape.
The three components, precisely
- The model, the reasoning engine. It takes the running conversation (goal + all prior tool calls + all tool results) and decides what to do next: call another tool, or stop and answer.
- Tools, functions the model can call. A tool has a name, a description, and a schema for its arguments. Examples:
web_search(query), query_db(sql), send_email(to, subject, body), run_python(code). Tools are how the agent reaches the outside world.
- The loop, the orchestration code that runs the cycle: send context to the model, parse its choice, execute the tool if one was called, append the result, repeat until the model says "I'm done" or a stop condition fires (max steps, timeout, cost cap).
Agent vs LLM call, side by side
A worked example: "Book me a flight to Austin next Thursday"
Watch the loop run:
- Turn 1 - model thinks: "I need to know what Thursday means. Today's date would help." → calls
get_current_date().
- Tool result:
2026-04-19. Appended to context.
- Turn 2 - model thinks: "Thursday is 2026-04-23. I need flights from the user's home airport to AUS on that date." → calls
search_flights(from: "DFW", to: "AUS", date: "2026-04-23").
- Tool result: a list of 6 flights with times and prices.
- Turn 3 - model thinks: "Before I book, I should confirm preferences." → calls
ask_user("Morning or evening? Budget?").
- User replies: "Morning, under $300."
- Turn 4 - model thinks: "The 8am flight at $247 matches." → calls
book_flight(id: "AA1234").
- Tool result: confirmation number. Model stops. Replies to user with the booking.
Same model that would have hallucinated a fake flight number in a one-shot prompt, now actually books a real flight. The difference is the loop and the tools.
The autonomy spectrum
"Agent" covers a wide range. Here's roughly where real systems sit:
Most production agents you'll build sit in the middle: a bounded loop with maybe 3-10 tools, running for 5-30 steps, with a timeout. The "fully autonomous agent that runs for days" is rare and hard. Don't start there.
When agents pay off
- The task needs information the model doesn't have. Current data, your private database, anything post-training-cutoff.
- The task is multi-step and each step depends on the previous one. You can't write a single prompt because you don't know step 3 until step 2 finishes.
- The task requires real-world actions. Send the email, write the file, create the ticket.
- The task benefits from self-checking. Write code, run tests, see failures, fix. Research a topic, verify claims, correct errors.
Pitfalls people hit early
- Using an agent where a prompt would do. If one well-written prompt produces the answer, don't wrap it in a loop. Agents are slower, more expensive, and less reliable than a single call. Start simple.
- No stop conditions. Agents happily loop forever if you let them. Always set a max step count and a cost cap.
- Too many tools. Ten tools means the model has to pick correctly ten ways. Fewer, sharper tools beat a kitchen sink.
- Vague tool descriptions. The tool description is the prompt the model sees. A bad description guarantees misuse.
- Treating agents like magic. Garbage prompts, garbage tools, bad base model reasoning, bad data → garbage agent. The loop doesn't fix any of that.
What to do with this
- Read agent vs workflow to figure out which shape actually fits your task.
- Then when not to use agents - the decision that saves the most money.
- When you're ready for the mechanics, ReAct is the loop pattern you'll write first.
Further reading
Watch
Andrej Karpathy - Intro to Large Language Models (1 hour)