Expand description
Session memory envelope + local compaction helpers, shared by every
compaction path (auto, manual /compact, model-switch, recovery, fork).
This module was extracted from the binary unified runloop so that both the
binary runloop and the vtcode-core AgentRunner loop use a single
compaction path with identical continuity behavior.
Structs§
Enums§
Constants§
- APPLIED_
INTENT_ WINDOW - DEDUPED_
FILE_ READ_ NOTE - DEFAULT_
OUTPUT_ RESERVE_ TOKENS - Conservative output reservation when the request does not declare a limit.
- MEMORY_
ENVELOPE_ HEADER - MEMORY_
ENVELOPE_ SUFFIX - MEMORY_
LIST_ LIMIT - SESSION_
MEMORY_ ENVELOPE_ SCHEMA_ VERSION
Functions§
- build_
session_ memory_ envelope - build_
zero_ cost_ summarized_ fork_ history - configured_
retained_ user_ messages - dedup_
repeated_ file_ reads_ for_ local_ compaction - default_
memory_ envelope_ path_ for_ session - derive_
continuity_ summary - effective_
compaction_ threshold - effective_
compaction_ threshold_ with_ reserve - effective_
context_ budget - Resolve catalog/dynamic model capacity and the provider’s route-specific ceiling.
- effective_
session_ context_ budget - Zero means unknown/unconfigured; positive limits are intersected.
- has_
latest_ memory_ envelope - inject_
latest_ memory_ envelope - insert_
memory_ envelope_ message - latest_
memory_ envelope_ path_ for_ session - latest_
memory_ envelope_ path_ for_ session_ async - Find and deserialize the newest valid envelope without synchronously scanning historical candidates on the runtime thread.
- load_
latest_ memory_ envelope - load_
latest_ memory_ envelope_ async - local_
compaction_ config - memory_
envelope_ file_ matches_ session - Whether a history envelope filename belongs to
session_id. - persist_
memory_ envelope - Persist the recoverable full-history artifact and build + inject a session memory envelope into the compacted history. Returns the envelope (with the artifact path) when one was produced.
- persist_
memory_ envelope_ async - Async counterpart to
persist_memory_envelope. Compaction runs on the async agent loop, so filesystem work must not block the runtime while the recoverable history artifact or envelope is being written. - persist_
memory_ envelope_ async_ with_ update - Async variant of
persist_memory_envelope_asyncthat applies a live session update while constructing the envelope. - persist_
memory_ envelope_ with_ update - Variant of
persist_memory_envelopethat applies a live session update while constructing the envelope. Keeping the compatibility wrapper above avoids changing synchronous callers that do not track steering state. - read_
task_ tracker_ snapshot - read_
task_ tracker_ snapshot_ async - Read the task tracker without blocking the async runtime.
- resolve_
compaction_ threshold - Resolve a prompt threshold while preserving room for the next response.
- resolve_
compaction_ threshold_ with_ reserve - resolve_
effective_ compaction_ threshold - Explicit trigger overrides can reduce, but never bypass, the session ceiling.
- sanitize_
session_ id - Sanitize a session id the same way history envelope filenames do (32-char ASCII-safe prefix). Callers that match envelope names must use this, not the raw session id.
- should_
persist_ memory_ envelope - strip_
existing_ memory_ envelope - write_
memory_ envelope_ to_ path - write_
memory_ envelope_ to_ path_ async - Atomically replace an envelope from an async context. The temporary file is created beside the destination so rename remains atomic on the same volume.