API lesson 02 · Assemble event streams
Shared system · deterministic provider fixtures
Harbor Support Drafting API. One bounded request moves through typed items, tools, state, budgets, and evidence without live provider calls.
01 · Smallest useful mechanism
Streaming clients must correlate content blocks, accumulate deltas, tolerate keep-alives, handle cancellation, and finalize only after the documented terminal event.
Partial text and partial JSON are previews, not validated final values.
02 · Experiment
Deterministic protocol fixture
This workbench uses inspectable provider-event fixtures and injected failures. It does not make live calls or execute external effects.
Protocol workbench · harbor-stream-v2
Injected failure
The stream ends after `{"policy_` without a completion event.
The trace has not run.
Commit to an implementation, then inject the failure and inspect the actual state transitions.
03 · Implementation brief
Your learning artifact
Stored only in this browser. No account required; course reset does not delete it.
04 · Check your understanding
Primary sources · verified 2026-08-02
A smooth typewriter effect can conceal duplicated text, malformed tool arguments, lost terminal usage, or work that continued after the user cancelled.
Common mistake: Every chunk is independently safe to render or parse. Chunks may split Unicode, words, citations, or JSON tokens. Accumulate according to the event contract and apply moderation and validation at the correct boundary.
Transfer exercise: Reorder, duplicate, and truncate the fixture events; make the assembler reject impossible transitions without losing the diagnostic trace.
Next: A correct stream can deliver structured output, but structure alone does not make the values true or authorized.