Expand description
Rolling state block (SPEC_DURABLE_CONVERSATION_MEMORY_2026_09_23.md §4.4,
“Generation”). The continuation packet (continuity.rs) carries the
recent exchange verbatim; this keeps a running summary of the whole
conversation, so a fresh session that can’t resume (an account switch,
say) also learns the goal, what’s done, what’s pending and what the user
prefers from before the verbatim tail begins.
Updated off the launch path: after a successful turn, when enough has
happened since the last version, one Haiku call folds the new turns into
the previous state. At most one update runs per agent. Each update is an
immutable version appended to STATE_FILE in the agent’s global
agent:<defId>:current zone, so it survives account and channel changes
the same way the transcript does. A failed update (the account is out of
quota, say) leaves the last good version in place.
Structs§
- InFlight 🔒
- State
Version 🔒
Constants§
- COMPACTION_
CLAUSE 🔒 - The clause
memory-reinjection.ts(REASON_CLAUSE.compaction) puts in a reinjection sent after the provider compacted the conversation. - LATEST_
WINDOW_ 🔒BYTES - A state version is well under this; reading the file’s last window finds the newest without reading every version.
- NEW_
TURNS_ 🔒BUDGET_ CHARS - New turns handed to the summarizer. The newest are kept.
- READ_
CAP_ 🔒BYTES - The most transcript read per update. Streaming deltas are most of it.
- REQUIRED_
HEADING 🔒 - The heading the summarizer must produce. Output without it is rejected rather than stored.
- STALE_
AFTER_ 🔒MS - With fewer new person turns, update anyway once the last version is this old.
- STATE_
FILE 🔒 - Append-only, one JSON
StateVersionper line. Cleared with the rest of the zone when the user starts a new conversation (archive.rs). - STATE_
MAX_ 🔒CHARS - Longest state block kept: about 3k tokens, the §4.4 budget.
- TURNS_
PER_ 🔒UPDATE - Person turns since the last version that trigger an update.
Functions§
- accept_
state 🔒 - The summarizer’s reply as a state block to store, or
Nonewhen it isn’t one (a refusal, an error message, a truncated reply). - after_
successful_ 🔒turn - Called when a turn ends successfully. Returns at once; any update runs in the background.
- append_
state_ 🔒to_ reinjection - Inserts the summary as the reinjection’s last section.
- append_
version 🔒 - eligible 🔒
- What an update needs from the block, or
Nonewhen the block doesn’t get a state block: not a Claude agent (the summarizer runs the agent’s own CLI), not anchored to an agent definition, or opted out withagent:continuity = off(§4.7). - in_
flight 🔒 - Agents with an update running. One at a time per agent: a turn that ends mid-update is picked up by the next turn’s check, not by a second call.
- latest_
state 🔒 - The newest state version for
zone, when it describes the conversationzoneholds now. A version that covers more bytes thanoutputhas left belongs to a conversation that has since been archived. - latest_
state_ 🔒for_ block - person_
turns 🔒 - running_
summary_ 🔒section - The agent’s running summary as the section a compaction delivery carries
last — the
SessionStarthook’s (memory_delivery), formatted exactly as the hidden reinjection’s.Nonewhen the agent has no summary yet. - should_
update 🔒 - Whether the person turns since
latestwarrant a new version. - summarizer_
prompt 🔒 - summary_
section 🔒 - The summary under its
#heading, ending in a newline. The frontend’s replay parser ends the Personal Memory section at this heading (RUNNING_SUMMARY_HEADINGinmemory-reinjection.ts). - update 🔒
- with_
state_ 🔒after_ compaction messagewith the agent’s running summary added, when it is the hidden memory reinjection sent after a compaction (§4.4, “Compaction reuse”): the provider’s own compaction summary can drop commitments, and this is the backstop. Any other message, or an agent with no summary yet, comes back unchanged.- without_
trailing_ 🔒chatter textwithout a closing paragraph addressed to the reader. Despite the prompt, the model sometimes ends by answering the conversation it was summarizing (“Yes, done. Should I continue?”). The last section is a list, so a plain paragraph after a blank line there is not part of the state.