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
Persisting across launches
A desktop app is expected to remember. Conversations are plain values, so writing them as JSON under the app’s user-data directory is enough. Persist the array, not SDK state: models reload from disk on the next launch, and history is all you need to carry.Context length
Trim before the conversation outgrows the model’s window, keeping the system message:contextLength at load time, which pushes this problem further
out but does not remove it.