Search & retrieval
Web search, docs lookup, vector-DB retrieval. Gives the agent facts beyond its training data.

An AI agent is a model wired into a loop: it takes a goal, picks tools, acts, observes the result, and repeats until done. A chatbot answers. An agent does things — searches, runs code, calls APIs, edits files — then checks its own work.
If you can use an LLM API and write a while loop, you can build a basic agent today.
| Chatbot | Agent | |
|---|---|---|
| Input | One message | A goal (“book me the cheapest flight Friday”) |
| Behavior | Single response, then stops | Loops: reason → act → observe → repeat |
| Tools | None (just text) | Search, code execution, APIs, file access |
| State | Forgets between turns (mostly) | Keeps working memory across steps |
| Failure mode | Wrong answer | Wrong actions (the expensive kind) |
A chatbot with a search button is not an agent. An agent decides by itself when to search, what to search, and what to do with the result.
Every agent, from a 50-line script to a production coding assistant, runs some version of this loop:
Perceive — Gather context: the goal, conversation history, tool outputs from previous steps.
Reason — The model decides the next move: which tool to call, with what arguments, or whether the goal is done.
Act — Execute the tool: run the search, hit the API, write the file.
Observe — Feed the tool’s output back into context. Success? New error? Updated state?
Repeat — Go back to step 1 until the goal is met, the step budget runs out, or a human interrupts.
Tools are just functions the model is allowed to call, described with a name, a schema, and a short description. Common categories:
Search & retrieval
Web search, docs lookup, vector-DB retrieval. Gives the agent facts beyond its training data.
Code execution
Run Python, SQL, or shell in a sandbox. Lets the agent compute, transform data, and verify.
API actions
Create tickets, send messages, book, deploy. This is where agents become genuinely useful — and risky.
File & memory
Read/write files, notes, and long-term memory. Lets work persist across steps and sessions.
Start with read-only tools (search, read files). Add write tools (send, delete, deploy) only with explicit confirmation gates.
You don’t need a framework to use these — they’re just ways of structuring the loop.
The model interleaves thinking traces with tool calls: thought → action → observation → thought… Simplest pattern, and the default for most agents. Works well for open-ended tasks under ~15 steps.
The agent writes a plan first, then executes each step (possibly with a separate executor model). Better for multi-stage tasks where you want to review the plan before anything runs. Re-plan when a step fails.
Split the job: a planner, a researcher, a coder, a reviewer. Each gets narrow instructions and tools. More setup, more failure surfaces — but better for complex work where one context window gets muddy. Only reach for this when a single agent demonstrably struggles.
You need: an LLM API with tool calling, 3–5 tools, and the loop above. Concretely:
Pick one narrow goal. “Summarize today’s Hacker News top 5 with links” beats “be my research assistant.” Narrow goals are debuggable.
Give it 2–3 read-only tools. Web fetch, search, and file-write (to save the summary). That’s enough for a first loop.
Write the loop with a step budget. max_steps = 10. Log every thought, action, and observation — you’ll read these logs more than any other artifact.
Add one guardrail. Require human confirmation before any irreversible action. Even for a toy agent, build the habit.
Evaluate on 5 examples. Run the same goal 5 times, note where it wanders. Fix context and tool descriptions before touching the model or framework.
Rule of thumb: code the predictable parts, agent the unpredictable parts. The best systems are hybrids — deterministic scaffolding with agentic steps inside.