Methods to understand
Streaming responses should support cancellation and show their state when interrupted. Partial output has not passed full validation and must not be saved as a final structured result. Keep a complete response for comparison.
Apply the method to a scenario
Goal: complete a clearly scoped work task using AI. Input: public, task-relevant material. Acceptance: verifiable results and explicitly marked unknowns.
Hands-on workshop
Understand streaming and cancellation without treating partial output as complete.
- Confirm the streaming event format for the specific model API.
- Read response chunks in the browser; handle events separately from transport bytes.
- Simulate interruption and verify states and that cancelled output is not saved.
const controller = new AbortController();
const response = await fetch("/your-stream-endpoint", { signal: controller.signal });
if (!response.ok || !response.body) throw new Error("Stream unavailable");
const reader = response.body.getReader();
const decoder = new TextDecoder();
let buffer = "";
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
// Parse buffer using the documented SSE / JSON event protocol; do not guess fields.
}
// Call controller.abort() when the user cancels.How to verify
Test completion, cancellation, and server disconnection separately and record the resulting states. Replace the sample endpoint with your actual implementation.
Practice task
Choose a case related to your work and practice "Implement streaming interactions". Submit inputs, steps, results, and verification records.
- Explain the task goal and inputs
- Provide actual results or runnable deliverables
- Identify errors, limits, and verification evidence
Saving a record documents your practice. It does not automatically grant certification.