KatInterview

Design a Streaming Conversational AI Assistant

System DesignModel answer
HardModel answerSystem DesignstreamingLLM inferencedistributed systems

Last updated

Design the backend architecture for a multi-turn AI chat product with streaming responses, session history, safety controls, and optional tool integrations.

Design a Streaming Conversational AI Assistant

You are asked to design the backend system for a conversational AI product — think of something like a general-purpose chat assistant users interact with through a web or mobile interface.

Your system must support:

  • Multi-turn conversations where the model has access to prior context in the session
  • Token-by-token streaming so responses appear progressively rather than all at once
  • High availability and low latency under peak traffic conditions
  • Basic safety controls including input toxicity checks, PII handling, and prompt injection awareness
  • Optional tool use, such as routing the model's request to a search index or a calculator service

Walk through your high-level architecture, key data models, how you would scale the inference layer, and how you would measure quality and safety in production.

What the interviewer is looking for:

  • Explicit assumptions and back-of-envelope numbers before diving into design
  • A clear API contract that handles streaming and error states
  • An honest treatment of GPU inference as the system's primary bottleneck
  • Concrete strategies for context truncation, streaming reliability, and graceful degradation
  • Safety as a first-class concern rather than an afterthought

Hints

Hint 1

Start with scale: estimate daily messages, peak concurrency, and output token throughput. This math will justify every major architectural decision that follows, especially around inference capacity.

Hint 2

GPU inference is the dominant bottleneck and cost center. Discuss continuous batching, KV-cache management, prefix caching, and autoscaling triggers — these are the details that separate a strong answer from a shallow one.

Hint 3

Think through what happens when a client disconnects mid-stream, when the model produces a partial reply, or when a user edits an earlier message. Reliability at the streaming and persistence layer is easy to overlook but will come up as a follow-up.