Design a Streaming LLM Edit Application System

Last updated: May 21, 2025

Quick Overview

Design a system that applies LLM-generated code edits to files as tokens stream in. Handle partial edits, syntax validation, user interruption, and rollback when the generation goes wrong.

Cursor
System Design
Software Engineer
Cursor
May 21, 2025
Software Engineer
Onsite - System Design
System Design
Medium

13

9

2,402 solved


Design a system that applies LLM-generated code edits to files as tokens stream in. Handle partial edits, syntax validation, user interruption, and rollback when the generation goes wrong.

Cursor applies AI edits in real time as the model generates tokens. This creates unique challenges around partial state, user experience during streaming, and error recovery. The interviewer expects you to think about the UX of streaming edits as much as the technical infrastructure.

What the Interviewer Expects
  • Design the streaming pipeline from model output to editor state updates
  • Handle partial edits that are syntactically invalid mid-stream
  • Implement user interruption and rollback to pre-edit state
  • Discuss diff visualization during streaming for user review
  • Address error handling when the model produces invalid or harmful edits
Key Topics to Cover
Streaming systems design
Editor state management
Diff algorithms and visualization
Error recovery and rollback
Real-time user experience
How to Approach This
  1. Start by clarifying functional and non-functional requirements with the interviewer.
  2. Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
  3. Draw a high-level architecture first, then deep dive into 1-2 critical components.
  4. Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
  5. Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
  • How would you handle a streaming edit that modifies a file another user is editing?
  • How would you implement 'accept partial' where the user keeps some generated lines but not others?
  • What happens if the connection drops mid-stream?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice System Design Problems
Sample Answer
Streaming Pipeline

The model generates tokens via server-sent events (SSE). A client-side stream processor accumulates tokens into a structured edit plan. The edit plan ...

Partial State and Interruption

Mid-stream, the edit is syntactically incomplete. The diff view shows the current state with a streaming indicator. Syntax highlighting operates on th...


Submit Your Answer
Markdown supported

Related Questions