androidengineers.Book a session

Software foundations · Web and full-stack requests

Streaming responses, sessions, and cancellation

articleSelf-paced

Streaming sends partial output before a response is complete. It can improve perceived responsiveness, but it introduces partial states and interruption behavior. The application must distinguish an incomplete stream from a committed result.

Associate events with a request or turn ID so late output cannot replace a newer request. Cancel unnecessary work when the user leaves or interrupts, while recognizing that a completed external action cannot be undone by closing a connection. Reconnection should recover known state rather than blindly repeat a mutation.

A session identifies related interaction, not unlimited authority. Recheck permissions for protected actions and scope conversation history to the correct user. Keep transport details separate from durable task state.

Exercise: simulate a stream that stops halfway, then starts a second request. Deliver late events from the first request and verify they are ignored by the current UI.

Check: partial output is visibly incomplete and a reconnect cannot duplicate an already committed action.

YOUR LEARNING JOURNEY

0 of 89 available lessons completed

Progress saved in this browser. No account needed.
Streaming responses, sessions, and cancellation | AI Engineer | Android Engineers