AI & ML Quick Path

Capstone 5 of 8

Order-returns agent with human approval

AI applicationAdvancedEffort 25–40 h (estimate)

Business requirement

A shop wants an assistant that can look up orders, check the returns policy and prepare refunds, but a staff member must approve every refund.

Lessons to finish first

Architecture

  1. Chat front end
  2. Agent loop (model chooses tools)
  3. Tools: get_order, check_policy, propose_refund
  4. Approval step before any refund
  5. Audit log
  6. Test scenarios including attacks

Build steps

  1. Create a fake orders table and a short returns policy.
  2. Write three tools with strict input schemas; propose_refund only creates a pending request.
  3. Build the agent loop: the model picks a tool, your code runs it, the result goes back to the model.
  4. Add the approval step: a person accepts or rejects; only then is the refund recorded.
  5. Check permissions inside each tool (a customer can only see their own orders).
  6. Write 20 scenarios: normal returns, out-of-policy requests, missing orders and prompt-injection attempts.
  7. Log every tool call with inputs, outputs and the approver.

Python route and .NET route

Python
LangGraph (state graph, interrupt for approval, checkpointer) or plain Python with a loop. Start from the returns-workflow example.
.NET (C#)
Microsoft Agent Framework or Microsoft.Extensions.AI function calling (AIFunctionFactory), with an approval-required function wrapper; ASP.NET Core for the API.

Example input and output

Input
"I want to return order 1042, it arrived broken."
Output
"Order 1042 qualifies (within 30 days, damaged). A refund of 49.00 is waiting for staff approval."

Data

Fake orders generated by a script.

Starter file structure

Structure (Python file | .NET project)
agent/
  tools.py | Tools.cs
  graph.py | Agent/Program.cs
  scenarios/*.json
  README.md

Tests

  • No refund is recorded without approval
  • Customer A cannot see customer B’s order
  • Injection in an order note does not trigger a tool call
  • Out-of-policy request is refused with the reason

How it will be judged

  • Least-privilege tools
  • Approval cannot be skipped by the model
  • Full audit trail
  • Scenario pass rate reported

Security and privacy

Enforce permissions and approval in code, not in the prompt; never give the agent a tool that moves money directly.

Definition of done

  • 20 scenarios with results
  • Approval demonstrated in a recording
  • Audit log shows every action

Stretch goals

  • Use the RAG assistant from capstone 4 for policy questions
  • Add a cost cap per conversation
  • Add an escalation path to a human agent

What to show an employer

Scenario results table and a demo of an approved and a rejected refund.

Completion

Saved in this browser only.