Lesson 25 of 40AI in production
Designing AI Experiences
Design the product around a model with streaming, sources, honest uncertainty, edit and retry, feedback that feeds evals, refusals, handoff and accessible chat.
A model that gives a great answer can still be a bad product. If the answer takes eight seconds behind a frozen spinner, cites nothing, sounds equally sure when it is wrong, and offers no way to fix a misunderstanding, users stop trusting it after the second mistake. The previous lessons covered the plumbing: structured output, retries, fallbacks, retrieval. This lesson is about the part users actually touch. You will see how to make waiting feel short, how to show where an answer came from, how to be honest about uncertainty, how to let people correct and rate the output, and how to make a chat interface work for everyone, including screen reader users. It ends with the most important design decision of all: when not to use AI.
The model is one part of the product
Traditional software is fast and predictable: the same click gives the same result in milliseconds. A model is the opposite. It is slow (seconds, not milliseconds), probabilistic (the same question can get different answers) and sometimes wrong in a fluent, convincing voice. Good AI UX is mostly about designing around those three facts instead of hiding them.
A useful way to think about it: the interface has to do the jobs a careful human expert does without being asked. An expert says "give me a moment", shows their sources, says "I am not sure about this part", lets you correct them, and knows when to pass you to someone else. Every pattern in this lesson is one of those habits turned into a screen element.
Latency budgets and skeletons
A latency budget is the maximum time you allow each part of a response to take, decided before you build. For AI features, two numbers matter more than total time:
- Time to first token (TTFT): how long until anything appears. This is what users feel as "slow".
- Time to complete: how long until the answer is finished and usable.
Long-standing usability research gives rough thresholds: around 0.1 seconds feels instant, around 1 second keeps the user's flow, and beyond about 10 seconds people lose focus and start doing something else. A model rarely hits the first, so design for the other two. Within the first second, show that work has started: a skeleton (grey placeholder lines in the shape of the answer) or a short status. For anything that runs longer, show progress the user can understand, such as "Searching your documents", "Reading 3 sources", "Writing the answer". Agents that take minutes should say what step they are on and let the user leave and come back.
The clock starts. The input is disabled and a Stop button appears straight away.
Streaming and progressive display
Streaming means sending the answer in pieces as the model generates them. For text a person reads, it is the single biggest UX improvement you can make, because people start reading while the rest is still being written. The demo below fakes a token stream with timers, so it runs with no network. Press Ask, then try Stop halfway, then Retry.
Preview
A few details in that small demo are worth copying:
- The skeleton appears instantly, before the first token, and is replaced by text, not added below it.
- Stop is always available while streaming. Users who can see the answer is going the wrong way should not have to wait for it to finish.
- Sources and feedback appear at the end. Showing buttons for a half-written answer invites people to rate something they have not read.
- Animations are switched off under
prefers-reduced-motion, so the pulsing skeleton and blinking caret do not bother people who asked their system for less motion.
Two cautions. Do not stream structured data your code parses (a JSON ticket, a form fill); wait for it to be complete and valid, then render it. And if you render Markdown as it streams, expect half-finished syntax, such as a code block that has opened but not closed. Render partial Markdown tolerantly, or re-render the whole message on each update.
Showing sources and citations
When an answer is built from documents, as in the RAG lesson, show which documents. Put small numbered markers in the text, like [1], and a list of sources under the answer that open the original. Citations do two jobs: they let the user check a claim in one click, and they make wrong answers easier to spot, because a claim citing an unrelated document looks wrong.
Only show citations your code has checked. If the model cites [3] and you only sent two sources, drop the marker or flag it; a fake citation is worse than none, because it borrows trust it did not earn.
Signalling uncertainty honestly
Models sound confident whether or not they are right, so the interface has to add honesty back. Avoid invented precision like "94% confident"; a model's sense of its own certainty is not a calibrated probability, and users read numbers as facts. Instead:
- Let the model say so in words. Prompting it to state what it is unsure about ("I am not certain of the exact time for your bank") gives users something specific to check.
- Label AI-generated content clearly, so users know which parts to treat as a draft.
- Make "no answer" a valid, well-designed outcome. "I could not find this in the help centre" plus a link to search is far better than a guess.
- Match the warning to the stakes. A recipe suggestion needs no banner. A tax answer needs a clear "check this with the official guidance" and a link to it.
Edit and retry
The fastest way to fix a misunderstanding is to let the user change their question. Good AI interfaces let people edit a previous message and re-run from there, retry to get a different answer, and undo any action the AI took. If you keep earlier versions of a regenerated answer, let users flip between them; sometimes the first one was better.
For AI that changes things (drafts an email, edits a document, updates records), show a preview or a diff and require a confirmation step for anything that is hard to reverse. This is the same "model drafts, person approves" idea from AI Features in Production, turned into a screen.
Feedback buttons that feed evals
Thumbs up and thumbs down are only useful if the data goes somewhere. Make feedback cheap to give and rich enough to act on:
- Show the buttons on completed answers only.
- On thumbs down, offer a few reasons (wrong, unhelpful, unsafe, too long) and an optional comment.
- Log the rating with the request id, the prompt version and the model, so you can find the exact case.
- Review the bad ones weekly, and turn real failures into eval cases with the expected answer.
- Run every prompt or model change against that eval set before shipping.
Put the path from a thumbs down to a better product in order.
- Tap the steps below in the right order.
Guardrails users can see, refusals and handoff
Guardrails are the limits you put on what the feature will do: topics it covers, actions it can take, data it can see. Many live in code the user never sees, but some should be visible. Tell users up front what the assistant is for ("I can help with orders, returns and delivery"), and show a confirmation before any action with real consequences.
When the model refuses, or a guardrail blocks a request, never leave the user at a dead end. A good refusal says what you cannot do, briefly and without lecturing, and offers the next best step: a related thing you can do, a help article, or a person. Treat a refusal differently from an error. An error deserves "Something went wrong, try again"; a refusal deserves an alternative, because retrying will give the same answer.
Human handoff is the escape hatch: a visible way to reach a person, offered when the user asks, when the AI fails twice, or when the topic is high stakes. Pass the conversation along so the user never has to repeat themselves.
Match each problem to the UX pattern that addresses it.
Accessible chat interfaces
Chat UIs are easy to make inaccessible, because content appears without the user doing anything. Screen reader users need to be told about it, but not drowned.
- Use a live region (an element with
aria-liveor a role such asstatusorlog) so new content is announced. Live regions should already exist in the page before content is added to them. - Do not announce every token. A stream of fragments read aloud is unusable. Mark the message as busy while it streams (
aria-busy="true"), then announce a short status like "Answer ready", or the whole answer if it is short. - Keep focus predictable. Do not move focus into each new message; return it to the input or a sensible control when the answer finishes.
- Every control, including Stop, Retry, copy and feedback, must be a real button with a clear label and visible focus, usable by keyboard alone.
- Respect
prefers-reduced-motionfor typing effects and pulsing skeletons, as the demo does.
What not to build with AI
The best AI UX decision is sometimes to use no AI at all. Skip the model when:
- A deterministic answer exists. Totals, dates, unit conversions, permissions checks and form validation belong in plain code, which is faster, cheaper and always right.
- Mistakes are costly and hard to review. Sending money, deleting data or giving medical or legal decisions automatically, with no person approving.
- A simpler interface is better. A chat box in front of a five-option menu makes users type what they could have clicked.
- You cannot measure quality. If you have no way to tell good output from bad, you cannot improve it or notice when it gets worse.
- time to first token
- How long until the first piece of a streamed answer appears; the main driver of perceived speed.
- latency budget
- The maximum time each step of a response may take, agreed before you build.
- skeleton
- Placeholder shapes shown instantly where content will appear, so the interface feels responsive.
- citation
- A marker in an answer that links to the source document a claim came from.
- guardrail
- A limit on what an AI feature will discuss, see or do, enforced in code and sometimes shown to users.
- human handoff
- Passing a user, with the conversation so far, from the AI to a person.
- live region
- A page area marked with aria-live or a role like status, whose changes screen readers announce.