Search⌘ K
AI Features

Canonical Conversation State: What to Persist vs. Derive

Explore how to model and persist the canonical conversation state in AI chat applications. Understand what data must be saved versus what can be derived to ensure multi-turn conversations are durable and reloadable without losing context or replayability. This lesson helps you build a state model that correctly handles tool calls, assistant outputs, and user inputs for robust conversations across refreshes.

The last few lessons made sure a single structured response is safe to render. This chapter is about the conversation as a whole surviving longer than one response, including a reload. A chat UI can look correct until you refresh the page. One version reloads and shows the last assistant message, but it cannot explain why a tool result is visible, why a button is disabled, or why the assistant text appears twice. Another version reloads and reconstructs the same turn, including the tool call intent, the tool result, and the exact assistant output that followed.

That difference comes from what the app ...