Skip to content
AgenticAIWiki
  1. Learn
  2. Part 6
  3. 32. Designing AI products
  4. 32.1

Lesson 32.1 · 1 of 6 · 5 min read · Reviewed 24 Nov 2026

Designing for latency

By the end, you can

  • Design AI features around latency.
  • Use streaming and progress to keep users oriented.

Three kinds of wait

Wait Typical time Pattern
Chat reply 1 to 10 s Stream text; show the first words fast
Tool-using agent 10 s to minutes Show steps (“Searching orders… Reading 3 tickets…”)
Long job Minutes to hours Run in the background; notify when done; allow cancel

Make waiting purposeful

  • StreamStreaming: Receiving a response as a series of server-sent events while it is generated, instead of waiting for the whole reply. responses (1.6) so reading starts early.
  • Show progress for multi-step work, in plain words, not raw logs.
  • Let users act: cancel, refine the request, or keep working elsewhere.
  • Set expectations: “This usually takes about a minute.”

Reduce real latency

Lever Where
Smaller or faster model for simple steps 73.2, 73.4
Lower effort for easy routes 77.2
Prompt caching Chapter 70
Parallel tool calls 33.3
Shorter outputs (ask for concise answers) Part 2

Measure what users feel

Track time to first tokenTime to first token (TTFT): How long a user waits between sending a request and seeing the first token of the reply., time to final answer, and abandonment rate by feature. A design change that cuts perceived wait can matter as much as a faster model.

Key points

  • AI responses take seconds or minutes, so the interface must make waiting feel purposeful.
  • Stream text as it's generated; show steps for agents; let users keep working meanwhile.
  • Set expectations: say roughly how long a task will take and what's happening now.
  • Cut real latency too: smaller models for simple steps, caching, parallel calls, lower effort.
Hands-on labRuns in the Playground

Simulate streaming versus waiting

See how streaming and progress steps change what users see while a model works.

You will have: A table of first-view times and longest silent gaps for four requests, with users lost under each design.

Steps

  1. Fill in wait_for_all(): nothing shows until the last token.
  2. Fill in streamed(): text appears at the first token, and progress steps split the silent wait.
  3. Run it and compare the two columns.
  4. Change PATIENCE_S to 4 and see which requests still lose users.

Done when

  • Waiting for the whole answer loses 3 of 4 users.
  • Streaming with progress loses 0 of 4.
  • The agent request's longest gap drops below 2 seconds.

Open in the Playground No API key needed.

Starter code (Python)
# Compare what users see when they wait for a whole answer versus a streamed one.
# Illustrative model: a user gives up if nothing new appears on screen for more than 8 seconds.
PATIENCE_S = 8.0
requests_ = [  # (name, seconds before the first token, output tokens, tokens per second)
    ("short chat", 0.8, 120, 40),
    ("long answer", 1.2, 900, 40),
    ("report draft", 2.0, 1500, 35),
    ("agent with 3 tool steps", 6.0, 400, 40),
]


def wait_for_all(first_s, tokens, tps):
    # TODO: nothing is shown until the last token: first_s + tokens / tps. Return (first view, longest gap).
    return first_s, first_s


def streamed(first_s, tokens, tps, step_updates=0):
    # TODO: text appears at first_s. With progress steps, the silent wait splits into step_updates + 1 gaps.
    return first_s, first_s


lost = {"wait": 0, "stream": 0}
for name, first_s, tokens, tps in requests_:
    seen_w, gap_w = wait_for_all(first_s, tokens, tps)
    steps = 3 if "agent" in name else 0
    seen_s, gap_s = streamed(first_s, tokens, tps, steps)
    lost["wait"] += gap_w > PATIENCE_S
    lost["stream"] += gap_s > PATIENCE_S
    print(f"{name:<24} wait: first view {seen_w:5.1f}s | stream: first view {seen_s:4.1f}s, longest gap {gap_s:4.1f}s")

print(f"users lost, wait for all: {lost['wait']} of {len(requests_)}")
print(f"users lost, streamed with progress: {lost['stream']} of {len(requests_)}")
Show a solution
# Compare what users see when they wait for a whole answer versus a streamed one.
# Illustrative model: a user gives up if nothing new appears on screen for more than 8 seconds.
PATIENCE_S = 8.0
requests_ = [  # (name, seconds before the first token, output tokens, tokens per second)
    ("short chat", 0.8, 120, 40),
    ("long answer", 1.2, 900, 40),
    ("report draft", 2.0, 1500, 35),
    ("agent with 3 tool steps", 6.0, 400, 40),
]


def wait_for_all(first_s, tokens, tps):
    shown_at = first_s + tokens / tps
    return shown_at, shown_at  # first thing seen, longest gap with nothing new


def streamed(first_s, tokens, tps, step_updates=0):
    # Progress steps split the silent wait before the first token into shorter gaps.
    gap = first_s / (step_updates + 1)
    return first_s if step_updates == 0 else gap, gap


lost = {"wait": 0, "stream": 0}
for name, first_s, tokens, tps in requests_:
    seen_w, gap_w = wait_for_all(first_s, tokens, tps)
    steps = 3 if "agent" in name else 0
    seen_s, gap_s = streamed(first_s, tokens, tps, steps)
    lost["wait"] += gap_w > PATIENCE_S
    lost["stream"] += gap_s > PATIENCE_S
    print(f"{name:<24} wait: first view {seen_w:5.1f}s | stream: first view {seen_s:4.1f}s, longest gap {gap_s:4.1f}s")

print(f"users lost, wait for all: {lost['wait']} of {len(requests_)}")
print(f"users lost, streamed with progress: {lost['stream']} of {len(requests_)}")
Quick checkUsers abandon a feature that shows a spinner for 25 seconds before the full answer appears. What helps most?
How sure are you?
Pick an answer and how sure you are