Skip to content

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.

16 min read0/4 questions

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.

One answer, as the user experiences it
UserInterfaceYour serverModel APIAsks a questionSkeleton + 'Searching'RequestStreaming requestFirst tokensFinal tokens + stop reason

The clock starts. The input is disabled and a Stop button appears straight away.

1/6
Quick check
Your AI answer takes 6 seconds in total, and the first word appears after 4 seconds. Which change will users notice most?
Need a nudge? A hint rules out a wrong answer.

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.

HTML & CSS
<style> body { font: 15px/1.5 system-ui, sans-serif; margin: 12px; color: #111; } .row { display: flex; gap: 8px; margin-bottom: 10px; } button { font: inherit; padding: 6px 12px; border: 1px solid #444; background: #fff; cursor: pointer; } button:focus-visible { outline: 3px solid #1a5fd0; outline-offset: 2px; } button[disabled] { opacity: 0.4; cursor: not-allowed; } #answer { min-height: 90px; border: 1px solid #ccc; padding: 10px; } .skeleton div { height: 12px; background: #e3e3e3; margin: 8px 0; animation: pulse 1s infinite alternate; } .caret::after { content: "|"; animation: blink 0.8s steps(1) infinite; } @keyframes pulse { to { opacity: 0.4; } } @keyframes blink { 50% { opacity: 0; } } @media (prefers-reduced-motion: reduce) { .skeleton div, .caret::after { animation: none; } } #meta { font-size: 13px; color: #555; margin-top: 8px; } .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }</style> <div class="row"> <button id="ask">Ask</button> <button id="stop" disabled>Stop</button> <button id="retry" disabled>Retry</button></div><div id="answer" aria-busy="false">Ask: "How long do refunds take?"</div><div id="meta"></div><div id="status" class="sr-only" role="status"></div> <script> const ANSWER = "Refunds go back to your original payment method within 5 to 10 business days [1]. " + "If you paid by bank transfer it can take longer, and I am not certain of the exact time for your bank [2]."; const answer = document.getElementById("answer"); const meta = document.getElementById("meta"); const status = document.getElementById("status"); const [ask, stop, retry] = ["ask", "stop", "retry"].map(id => document.getElementById(id)); let timer = null; let started = 0; function fakeTokens(text) { return text.match(/\S+\s*/g); // word-ish pieces, like tokens } function setButtons(streaming) { ask.disabled = streaming; stop.disabled = !streaming; retry.disabled = streaming; } function run() { clearTimeout(timer); setButtons(true); started = performance.now(); meta.textContent = "Searching help articles..."; status.textContent = "Generating answer"; answer.setAttribute("aria-busy", "true"); answer.innerHTML = '<div class="skeleton"><div></div><div style="width:80%"></div><div style="width:60%"></div></div>'; const tokens = fakeTokens(ANSWER); let i = 0; timer = setTimeout(function next() { if (i === 0) { answer.textContent = ""; answer.className = "caret"; meta.textContent = "First token after " + Math.round(performance.now() - started) + " ms"; } answer.textContent += tokens[i++]; if (i < tokens.length) { timer = setTimeout(next, 30 + Math.random() * 60); } else { finish("Sources: [1] Refund policy, [2] Bank transfers. Was this helpful?"); } }, 700); } function finish(note) { clearTimeout(timer); if (answer.querySelector(".skeleton")) answer.textContent = "(stopped before the answer started)"; answer.className = ""; answer.setAttribute("aria-busy", "false"); meta.textContent = note; status.textContent = "Answer ready"; setButtons(false); ask.focus(); } ask.onclick = run; retry.onclick = run; stop.onclick = () => finish("Stopped. The partial answer is kept; press Retry for a fresh one.");</script>

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:

  1. Show the buttons on completed answers only.
  2. On thumbs down, offer a few reasons (wrong, unhelpful, unsafe, too long) and an optional comment.
  3. Log the rating with the request id, the prompt version and the model, so you can find the exact case.
  4. Review the bad ones weekly, and turn real failures into eval cases with the expected answer.
  5. Run every prompt or model change against that eval set before shipping.
Put it in order5 steps

Put the path from a thumbs down to a better product in order.

  1. Tap the steps below in the right order.
Need a nudge? A hint shows where it starts.

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 the pairs0/5 matched

Match each problem to the UX pattern that addresses it.

Choose an item, then its match on the other side.

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-live or a role such as status or log) 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-motion for typing effects and pulsing skeletons, as the demo does.
Quick check
Which approach gives screen reader users the best experience with a streamed answer?
Need a nudge? A hint rules out a wrong answer.

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.
Key terms
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.