Prompting, lesson 10
Capstone: a prompt pipeline for a support desk
Templates, examples, structured output and tool calls working together.
This walkthrough uses ideas from across the module, especially "How a chat request is built", "Few-shot examples", "JSON that always parses", "Letting the model call functions" and "A budget for the context window".
Part 1. The desk on one page
Spoke & Chain, the bike shop from "How a chat request is built", gets about 2,000 support emails a day. A model reads each one, tags it, looks up the order if there is one, and drafts a reply. A person on the support team reads every draft and clicks send.
The model has one tool, lookup_order, which only reads. Its final answer is JSON, and your code saves the reply inside it as a draft. Nothing the model writes can reach a customer on its own. Here is one email going through.
Example 1.1
One email through the desk
- email in"Hi, where is order 4417? It was meant to arrive Friday. Ana"
An email arrives from [email protected]. Whoever wrote it, its text is only ever a user message.
- system prompt+tool+3 examples+2 articles+the email
Your code builds a fresh request from parts. The provider turns the messages into its chat template.
- tool calllookup_order("4417")
The model asks for a lookup. Code checks the order belongs to the sender before it runs anything, then sends the result back.
- {"summary": …, "label": "order", "order_id": "4417", "reply": …}checks pass→draft in the agent's queue
The answer comes back in the schema's shape. Code checks the label and length, and the draft waits for a person.
Your turn
The model can look up orders, and your code saves its drafts, but nothing in the desk sends email by itself. Why leave sending out?
Human in the loop
A person who approves a model's output before it takes effect. Here, a support agent reads every draft before it goes to a customer.
Part 2. Building the request
Keep going with Pro
You've done the first part. Pro opens the rest of this lesson, and every other one.
- Building the request
- The answer's shape, and the one tool
- What it costs, and what comes next
Prompting overviewSpotted a mistake? Tell us.