← All AI Agents & Tool Use modules

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

Capstone · synthesizing the complete agent architecture · about 35 minutes.

You have constructed every component. The loop (Module 1) surrounding a decision rule. Tools (Module 2) enabling action. The ReAct pattern (Module 3) for multi-step reasoning. Memory (Module 4) for retention and recall of facts. Planning (Module 5) for multi-component goals. Routing (Module 6) for tool selection. Guardrails (Module 7) for safety. This capstone integrates these components into a complete working agent and then addresses the most consequential design question of the course: under what circumstances should an agent not be employed?

The complete agent in operation

The system below is a complete agent applied to a real, multi-component request. The agent plans, routes each subtask to a tool, reasons across the resulting observations using ReAct, and completes the task — with guardrails enabled throughout. Every label displayed in the trace — Thought, Action, Observation, Answer — corresponds to a component developed earlier in the course. Click Run the agent.

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

The central design judgment: when not to employ an agent

Agent architectures are capable but expensive — slower, more costly, and less predictable than a single function call or single model inference. Each iteration of the loop incurs an additional model call; each tool invocation introduces an additional source of failure. The essential engineering judgment is identifying when the loop justifies its overhead and when it does not. A working heuristic: employ an agent only when the task genuinely requires multiple steps, multiple tools, or adaptation to results that cannot be determined in advance. When a single model call or conventional code suffices, the latter is almost always preferable.

The tasks below are drawn from real applications. For each, determine whether the task warrants a full agent architecture or whether a single model call (or conventional code) would be more appropriate.

This activity needs JavaScript.

The complete loop assembled in code
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 of code express the entire course content. Production agent frameworks — LangChain, the Assistants API, Claude's tool use — are this skeleton augmented with a more capable decide function and more comprehensive guardrails.

AI anchor — from generative models to action-taking systems This course track began with a model that predicts the next token. It concludes with a system that can reason, invoke tools, retain information, plan, route, and act in the external world — safely. This is the trajectory of contemporary AI: the language model provides the decision rule, and the agent provides the surrounding execution machinery and engineering judgment. The teams developing AI systems that take action on behalf of users are constructing precisely the architecture developed in this course — and the most effective among them are as disciplined about identifying when not to deploy an agent as about how to construct one.

Capstone — synthesis across the course

The following questions integrate material from across the course: the agent loop, tool invocation, ReAct, memory, planning, routing, guardrails, and the judgment of when to employ an agent.

This activity needs JavaScript.

Course complete — the AI track concludes You can now define what constitutes an agent, construct its loop, equip it with tools, chain its reasoning, manage its memory, plan its execution, route its tool selection, and ensure its safety — and you can identify when an agent is appropriate and when it is not. From next-token prediction to a safe, action-taking agent, you have traversed the complete architecture. This represents the current frontier of applied AI, and you understand its underlying mechanisms.
Summary: a complete agent is a loop wrapping a model that reasons (ReAct), invokes tools (routing), retains information (memory), plans multi-component goals, and operates safely (guardrails) — and the essential engineering judgment is to employ this architecture only when the task genuinely requires multiple steps, multiple tools, or adaptation to unknown results, and to use a single model call or conventional code otherwise.

← Back to all modules