CourseAI Engineering: The Complete Course · Module 9: Agents and Tool Use · part 72 of 105
Part 72 · Module 9: Agents and Tool Use

Lab: Build the returns agent with Priya's approval

15 min read·13 Oct 2026
Module 9 · Lab · About 70 minutes · Needs: lessons 1 to 4 of this module (tools, the loop with limits, state and checkpoints, frameworks)

What you are building

THE RETURNS AGENT, END TO END Aisha message model node limits first tools read orders approval Priya decides start_return re-checks SQLite checkpoint after every node: messages, counters, trace
The finished agent: the model (amber) proposes, your code (blue) reads orders, Priya's approval (green) stands before the one write, and SQLite (grey) saves every step.

This lab joins the four lessons into the returns agent Priya asked for: a LangGraph graph that reads orders, checks the 30-day window in code, and proposes start_return, which runs only after Priya approves it. Each tool returns a structured error instead of crashing. Every model call passes a step, time and cost check first. State is saved to SQLite after every node, so the paused return survives a restart. Each run keeps a short trace of what happened. You finish by running three scenarios: Aisha's in-window smart bulbs (order 6150, approved), her robot vacuum (order 5521, refused as out of window), and an order number that does not exist (recovered).

The rest of this course is yours to keep

This course is bought on its own, once, and stays readable afterwards, including the parts added to it later.