Skip to main content

Module continuity_state

Module continuity_state 

Source
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 🔒
StateVersion 🔒

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 StateVersion per 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 None when 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 None when 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 with agent: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 conversation zone holds now. A version that covers more bytes than output has 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 SessionStart hook’s (memory_delivery), formatted exactly as the hidden reinjection’s. None when the agent has no summary yet.
should_update 🔒
Whether the person turns since latest warrant 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_HEADING in memory-reinjection.ts).
update 🔒
with_state_after_compaction 🔒
message with 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 🔒
text without 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.