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