AI Engineering
/
AI Application Integration
/

Stream, stop, and replace a response

AI Application Integration · 90 minutes

Stream, stop, and replace a response

Explain how a streaming feedback UI shows partial output, what Stop really cancels, and how run IDs keep late events from an old attempt out of a new answer.

Easy
Conceptual

1.5 h

Used in interview rounds:

Technical Screen (Easy)

Step 1: The question

Using the feedback session, explain what the browser and the backend each own, then walk through steps 1 to 7: what the UI shows for R1 and R2, and what the client does at each step. Say what Stop does and does not cancel, how the late R1 event is kept out of R2, and how the UI announces state changes to screen-reader and keyboard users.

Make state visible

StateUser meaningTypical control
IdleReady for a requestSend
SubmittingRequest is being acceptedPrevent accidental duplicate submission
StreamingPartial response is arrivingStop
CompleteServer confirmed completionCopy, review, or continue
InterruptedResponse ended without completionReconnect or retry
Cancelled locallyUser stopped this client operationStart a new attempt if desired
FailedA defined error prevents continuationExplain and offer a suitable next action

Keep partial text when it helps the user, but label it accurately. Do not display a completed checkmark simply because some text arrived.

Scenario: the feedback session

Suppose a fictional coding-practice platform has an interview-practice assistant: a learner types an answer to an interview question, and the assistant streams written feedback into a chat thread.

How the platform works

  • The browser talks only to the platform's backend. The backend calls a model provider and saves every run.
  • Each submission starts a new run with its own ID (R1, R2, and so on). Every stream event the client receives carries the run ID it belongs to.
  • Stream events are delta (more feedback text), done (the backend finished and saved the full feedback), and error (the run failed, with a message).
  • POST /feedback-runs/{runId}/cancel asks the backend to stop a run. GET /feedback-runs/{runId} returns the run's saved status (running, completed, cancelled, or failed) and, when it is completed, the full feedback text.
  • The backend cannot resume a broken stream from the middle.
  • The assistant has no side-effecting tools.

Timeline

StepWhat happens
1The learner submits answer A. The backend accepts it as run R1, and R1's feedback starts streaming.
2After two paragraphs of R1 feedback, the learner presses Stop.
3The learner submits a revised answer B. The backend accepts it as run R2, and R2's feedback starts streaming.
4A delayed R1 delta event, already in flight when the learner pressed Stop, reaches the client's event handler.
5The response to R1's cancel request says R1 is already completed, with its full feedback saved.
6After three paragraphs of R2 feedback, R2's connection drops. No done or error event arrived for R2.
7R2's saved status on the backend is completed, with its full feedback saved.

Constraints

  • Use only the platform facts and timeline in the scenario
  • Keep the answer to about three minutes spoken

Deliverables

  • What the browser owns and what the backend must enforce
  • How the client reads the stream and decides a run is complete
  • What Stop does at step 2, and what it does not guarantee
  • How R1's late event and later status stay out of R2
  • Labels, announcements, focus, and scrolling during the session

Step 2: Hints

Optional. Each hint gives a little more away.

Step 3: Your answer

Kept in this browser. Saving your score below keeps a copy with it.

0 / 5000

Step 4: Reference answer

Step 5: Score yourself

Score each dimension 0, 1, or 2, then save the score to your history. Readiness thresholds are editorial estimates.

Grades your written answer against this rubric with your own AI provider key from Settings. It is a second opinion: the score you save is still yours.

Client and server separation
Streaming semantics
Cancellation
Stale-event handling
Accessible UX

0 of 10 · Scored 0 of 5 dimensions

Ready at 8 of 10, with no 0 in Streaming semantics

Kept in this browser until you sign up, then it moves to your account.

Complete this level when you can walk through all seven steps of the feedback session, naming each run's state and the client's action, without confusing connection state with task completion.

Your saved scores

Practice saves and mock interview answers on this question, newest first.

No saved scores yet. Score every dimension, then save.

Step 6: Follow-up questions

An interviewer may ask these next.

Is a network chunk a token?

Does the end of a stream (EOF) mean success?

What does Stop cancel?

Why track run IDs?

Why avoid token-by-token announcements?

Step 7: Mark complete