Module 8 — Build an Agent, and Know When Not To
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.
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.
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.