How messages are split
The array is not sent verbatim:- System turns become
options.systemPrompt. - The trailing user turn becomes the prompt.
- Everything between travels as history.
Streaming a conversation
Keeping a transcript
ChatMessage
Context length
Trim before the conversation outgrows the model’s window, keeping the system message:Persisting across reloads
Conversations are ordinary values, soIndexedDB or localStorage both work. Persist the
array, not the SDK state: models reload from disk on the next visit, and history is all you
need to carry.