AI SDK Internals
Vercel AI SDK internals as they matter for building production agents — three-layer API, lifecycle ordering, message reference model, prepareStep semantics. Based on ai@^6.
AI SDK Internals
Why Vercel AI SDK internals deserve their own chapter — three-layer API, version pinning, reading order
Runtime Lifecycle
The full timeline of a single agent.stream() call — 12 callback firing points across three layers, two-layer same-named callback comparison, stopWhen / timeout default chains
UI Stream Orchestration
L3 UI-stream — the two paths contrasted / createUIMessageStream's execute-driven mode / three writer methods / custom data-* event protocol / transient semantics / error capture tiering
Message Reference Model
The four message chains and their reference relationships — why mutate is permanent pollution, push is truly ephemeral, and replacing arrays hinges on element identity
prepareStep Semantics
Full signature of the per-step hook, 7 overridable fields, 4 typical patterns, and a deep analysis of the mutate-vs-push trap