Design an Embeddable Streaming Chat Interface
Company: Google
Role: Frontend Engineer
Category: System Design
Difficulty: hard
Interview Round: Onsite
# Design an Embeddable Streaming Chat Interface
Design an embeddable chat-agent widget. Cover the host-page integration, streaming responses over SSE or gRPC, long-conversation virtualization, chat-history caching, and core product and reliability metrics.
### Constraints & Assumptions
- The widget may run inside a host application with its own authentication and styles.
- Assistant output arrives incrementally and may fail or be cancelled.
- Long histories cannot all remain mounted in the browser.
### Clarifying Questions to Ask
- Is the widget an iframe, web component, or library integrated into the host DOM?
- Must conversations synchronize across devices?
- Which guarantees apply to message ordering and resuming a broken stream?
```hint Define message states
Represent pending, streaming, complete, failed, retried, and cancelled messages explicitly before choosing UI components.
```
### What a Strong Answer Covers
- Embedding boundary, authentication, accessibility, and style isolation.
- Streaming protocol, sequence numbers, retry or resume behavior, and cancellation.
- Virtualized history, pagination, caching, optimistic UI, and consistency.
- Metrics for latency, completion, errors, engagement, and user correction.
### Follow-up Questions
1. How would tool-call approval appear without allowing duplicate actions?
2. How would you avoid losing partially streamed content during navigation?
Overview: Design an embeddable chat-agent widget with resumable streaming, virtualized history, safe caching, accessibility, and meaningful metrics.