Status: current behavior. Scope: main sessions (querySourceForTask(taskType) === "main_turn") with a
session store. Subagents and workflow actors do not use a snapshot.
Provider prompt caches match the request prefix byte for byte, in the order tools → system → messages. Without a snapshot, the system blocks are rendered from the current code on every request. A new CLI version that changes a prompt section then changes the prefix of every older session after a cold resume. The snapshot records the system blocks a session sent and keeps sending them.
Tools are not recorded. Each request sends the tool list prepared from the current registry. MCP servers connect after the first request can start and can change their tools during a session, so a recorded tool list cannot stay fixed; a changed tool list changes the cache prefix from the tools onward.
One session_entry row per session:
runtime/prompt_snapshot, id <sessionId>:runtime-prompt-snapshot, written with
touchSession: false (it does not change the session list order);data:
{
model: { providerId, modelId } the session model the snapshot was rendered for
system: [{ role: "system", content, cacheControl? }, ...] the leading system messages
}
or the tombstone { cleared: true }. The row is overwritten in place. No table changes are needed:
session_entry.type is free text and data is JSON. Older CLI versions read only the entry types
they know, so they ignore this row.
The snapshot stores no version and no projection flags. Two values that differ per process or per
session are kept out of the system blocks: the ZCode Desktop part (presentation surface, rollout
switch, Gen UI availability) and the Gen UI visualization directory are part of the environment
announcement (see meta-user-context.md). The other system content is frozen until compaction by
design, also when a later launch would render it differently: the memory section (memory root and
switch), the identity sentence that the output style selects, and a custom system prompt.
The runtime loads the row when it restores a session (cold resume). A read failure or an invalid row counts as no snapshot and never blocks the restore. A new session starts without one.
modelSelectionScope !== "execution"). The new row replaces the old one.rebuildContextPrefix builds the system messages from the current code, then replaces them with the
snapshot's system messages when the snapshot applies to the model the prefix is built for. The
conversation history therefore carries the frozen prefix, and every request that reads the history
(main loop, compaction, memory extraction) sends the same bytes. Announcements still use the fresh
build result. A record captures the leading system messages of the request that records it.
meta-user-context.md).A system section added by a later CLI version (for example the token budget line, see
system-prompt-contract.md) reaches an existing session only after its next successful compaction
or session model change. Until then the session keeps its recorded system bytes; reminders that the
new version adds to the history are appended and do not change the sent prefix.