Category. Applied AI engineering, also full-stack.
Problem. Most agent demos let the model call whatever tools it likes, which is dangerous when the action moves money. A ticket that tells the model to ignore its instructions and refund ₹50,000 should be able to change what the model proposes, and nothing more.
Design (Figure 5.6). A FastAPI service runs each ticket through a LangGraph state machine: triage, gather context, propose, risk gate, human approval, execute, finalize. The model is offered only two read-only tools, lookup_customer and lookup_order. The write tools, draft_reply and create_refund, run in graph nodes after the gate. Structured outputs are validated with Pydantic, and an invalid answer gets one retry before the ticket escalates. The risk gate is plain Python with no model call. Every refund needs approval. A refund above the order total, a sender who doesn’t own the order, or low confidence all escalate, and a loop guard stops runaway tool calls. When approval is needed, the graph pauses at an interrupt checkpointed in Postgres, and a reviewer approves, edits or rejects in a React dashboard, even after a server restart. A reviewer’s edit goes through the same checks as the model’s proposal. Refunds use a unique key and a row lock, so a double click gets a 409 instead of a second refund. Every model call, tool call and decision is written to an audit trail with tokens, latency and cost, and the dashboard shows it as a trace.