How to build an AI agent — what one is, and when not to build one
What an AI agent actually is (a model, tools and a loop), how it differs from a plain API call or a workflow, the four ways to build one, and the four questions to ask before you do.
What an AI agent actually is
Strip away the hype and an AI agent is three things working together:
- A model (here, Claude) that reads a task and decides what to do next.
- A set of tools — functions *you* write in PHP that the model can ask to use: look up an order, search a database, fetch a page, send a draft.
- A loop: the model asks for a tool, your code runs it and reports the result, the model reads the result and decides again — until it has finished the job.
That loop is the whole difference between a chat box and software that does work. In a chat, the model answers once. In an agent, the model *keeps going*: check the order, then check stock, then draft a reply, then stop.
Two things in that picture matter more than anything else in this course:
- The model never runs anything itself. It only *asks*. Your PHP decides whether to run the tool, runs it, and sends back a result. That is where safety, permissions and cost control live — in your code, not in the model.
- The loop ends when the model stops asking. You must also be ready to end it yourself (a maximum number of turns, a budget), because a loop with no limit is a bill with no limit.
Three tiers, not one
Most "AI features" don't need an agent at all. Before building one, know which tier you're in:
| Tier | What happens | Example | |---|---|---| | Single call | One request, one response | Summarise this ticket; classify this email | | Workflow | Several calls in an order *your code* controls | Extract fields → validate → save | | Agent | The *model* decides which tools to call and in what order | "Sort out this customer's complaint" |
Start at the simplest tier that does the job. An agent is the right choice when the task is open-ended and the model genuinely needs to explore — not when you could have written the steps yourself.
Four questions before you build an agent
Ask all four. A "no" to any of them means stay at a simpler tier:
- Complexity — Is the task multi-step and hard to specify fully in advance? ("Resolve this complaint" yes; "extract the order number" no.)
- Value — Does the outcome justify more cost and more latency than a single call?
- Viability — Is the model actually good at this kind of task?
- Cost of error — Can mistakes be caught and undone (review, tests, rollback)? An agent that can email customers or refund money needs a human gate — you'll build one in lesson 9.
The four ways to build one
There are four distinct ways to build an agent on Claude. This course teaches the first two in depth and the third in the Advanced tier:
- The manual loop — you write the
whileloop yourself. You own everything. (Lessons 3–4.) - The Tool Runner — the official PHP SDK runs the loop for you; you only write the tool functions. The default for most agents. (Lesson 5.)
- Managed Agents — Anthropic runs the loop *and* hosts a sandbox where the tools execute; you configure an agent and start sessions. (Lesson 20, beta.)
- The Claude Agent SDK — a separate product that packages the Claude Code harness with built-in file, shell and web tools. It is not covered here; it's a different library with its own documentation.
The key idea behind all four: two independent questions — *who supplies the loop* and *who hosts it*. Options 1, 2 and 4 leave hosting to you (that's lesson 22); only Managed Agents hosts it for you.
What you'll build in this course
You'll build in PHP with the official Anthropic SDK, so every example is real and current. By the end of the Beginner tier you'll have a working support-desk agent that looks up orders, checks stock and drafts replies for a human to approve. The Pro tier makes it safe, cheap and durable (guardrails, cost control, caching, memory). The Advanced tier connects it to the wider world (MCP, multi-agent, Managed Agents) and puts it on real hosting.
One honest note before you start: agent features move fast. Where a feature is in beta, the lesson says so. Every price and limit in the course is dated so you know what to re-check.
Try it
Before writing any code, take a task you'd like to automate and answer the four questions above in writing. If it fails one, note the simpler tier that fits. That habit — deciding *whether* to build an agent before *how* — is the most valuable thing in this lesson.
That was lesson 1. The other 23 are one payment away.
Next up: Set up on localhost — the official PHP SDK and your first call. Buy once, read every lesson online with your progress saved, and keep the whole course as a Word file.
Get the course · ₹499$19