← All AI Agents & Tool Use modules

Module 8 — Build an Agent, and Know When Not To

Capstone · the judgment that ties it all together · about 35 minutes.

You have built every piece. A loop (Module 1) wrapped around a decision. Tools (Module 2) so it can act. The ReAct pattern (Module 3) to reason across steps. Memory (Module 4) to hold and recall facts. Planning (Module 5) to handle multi-part goals. Routing (Module 6) to pick the right tool. And guardrails (Module 7) to stay safe. This capstone snaps them together into one working agent — and then asks the most valuable question in the whole course: when should you not build one at all?

The whole agent, working at once

Below is a complete agent on a real, multi-part request. Watch it plan, route each subtask to a tool, reason across the observations with ReAct, and finish — all with guardrails on. Every label you see — Thought, Action, Observation, Answer — is a piece you now understand. Press Run the agent.

This activity needs JavaScript. The lesson below still covers everything.

The most important judgment: when NOT to use an agent

Agents are powerful and expensive — slower, costlier, and harder to predict than a plain function or a single model call. Each loop is another model call; each tool is another thing that can fail. The mark of real skill is knowing when the loop earns its keep and when it is overkill. A good rule: use an agent only when the task genuinely needs multiple steps, tools, or adaptation to results you can't know in advance. If a single call or a few lines of ordinary code would do it, that is almost always the better answer.

Below are real tasks. For each, decide: does this need a full agent, or would a single model call (or plain code) do the job better? You will get a score.

This activity needs JavaScript.

The whole loop, assembled — read only, nothing to install
def agent(goal, tools, max_steps=8):
    state = {"goal": goal, "history": [], "memory": Store()}
    for _ in range(max_steps):           # guardrail: step cap
        thought, action = decide(state)   # ReAct + routing (the model)
        if action.is_final: return action.text
        if action.name not in tools: break   # guardrail: validate
        if action.is_risky and not human_ok(action): break  # guardrail: approve
        obs = tools[action.name](action.arg)  # act → observe
        state["history"].append((thought, action, obs))  # memory

Twelve lines hold the entire course. Everything beyond this — LangChain, the Assistants API, Claude tool use — is this skeleton with a smarter decide and sturdier guardrails.

AI anchor — from "a model that talks" to "a system that acts" You started this course track with a model that predicts the next token. You end it with a system that can reason, use tools, remember, plan, route, and act in the world — safely. That is the arc of modern AI: the language model is the brain, and the agent is the body and the judgment around it. The teams building the AI that actually does things for people are building exactly what you just built — and the best of them are as disciplined about when not to use an agent as about how to build one.

Capstone check — tie it all together

The final questions span the whole course: the loop, tools, ReAct, memory, planning, routing, guardrails, and the judgment of when to use an agent. You will get a score.

This activity needs JavaScript.

You finished the course — and the track You can now explain what an agent is, build its loop, give it tools, chain its reasoning, manage its memory, plan its work, route its tools, and guard it — and you know when to reach for one and when not to. From next-token prediction to a safe, acting agent, you have seen the whole machine. This is the frontier of applied AI, and you understand how it works.
One-sentence summary: a complete agent is a loop wrapping a model that reasons (ReAct), calls tools (routing), remembers (memory), plans multi-part goals, and stays safe (guardrails) — and the real skill is using one only when a task truly needs multiple steps, tools, or adaptation, and reaching for a single call or plain code when it does not.

← Back to all modules