Skip to main content

Module memory_envelope

Module memory_envelope 

Source
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§

SessionMemoryEnvelope
SessionMemoryEnvelopeUpdate
TaskTrackerSnapshot

Enums§

MemoryEnvelopePersistence
MemoryEnvelopePlacement

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_async that applies a live session update while constructing the envelope.
persist_memory_envelope_with_update
Variant of persist_memory_envelope that 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.