Skip to main content

ContextSummarizationView

Struct ContextSummarizationView 

Source
pub struct ContextSummarizationView<'a> {
Show 26 fields pub messages: &'a mut Vec<Message>, pub deferred_db_hide_ids: &'a mut Vec<i64>, pub deferred_db_summaries: &'a mut Vec<String>, pub cached_prompt_tokens: &'a mut u64, pub context_manager: &'a mut ContextManager, pub server_compaction_active: bool, pub token_counter: Arc<TokenCounter>, pub summarization_deps: SummarizationDeps, pub task_supervisor: Arc<TaskSupervisor>, pub memory: Option<Arc<SemanticMemory>>, pub conversation_id: Option<ConversationId>, pub tool_call_cutoff: usize, pub subgoal_registry: &'a mut SubgoalRegistry, pub pending_task_goal: &'a mut Option<BlockingHandle<Option<String>>>, pub pending_subgoal: &'a mut Option<BlockingHandle<Option<SubgoalExtractionResult>>>, pub current_task_goal: &'a mut Option<String>, pub task_goal_user_msg_hash: &'a mut Option<u64>, pub subgoal_user_msg_hash: &'a mut Option<u64>, pub status_tx: Option<UnboundedSender<String>>, pub scrub: fn(&str) -> Cow<'_, str>, pub compression_guidelines: Option<String>, pub probe: Option<&'a mut dyn CompactionProbeCallback>, pub archive: Option<&'a dyn ToolOutputArchive>, pub persistence: Option<&'a dyn CompactionPersistence>, pub metrics: Option<&'a dyn MetricsCallback>, pub typed_pages: Option<Arc<TypedPagesState>>,
}
Expand description

Borrow-lens over all fields needed for compaction and summarization operations.

Every field maps to a specific sub-field of Agent<C> and uses a type from a crate below zeph-core in the dependency graph. Constructed in zeph-core using one literal struct expression; the borrow checker verifies disjointness.

The view covers: message history mutation, deferred summary queues, context-manager compaction state, provider handles for LLM calls, memory persistence for flushing, subgoal registry for context-compression strategies, and background task handles for non-blocking goal/subgoal extraction.

Fields§

§messages: &'a mut Vec<Message>

Full conversation history. Mutated by pruning, compaction, and deferred summary application.

§deferred_db_hide_ids: &'a mut Vec<i64>

SQLite row IDs to be soft-deleted after deferred summaries are applied.

§deferred_db_summaries: &'a mut Vec<String>

Summary strings paired with the hide IDs above — flushed to SQLite as a batch.

§cached_prompt_tokens: &'a mut u64

Running token count for the current prompt window. Updated after every mutation that changes message content.

§context_manager: &'a mut ContextManager

Full context manager — contains compaction state, thresholds, strategy config.

§server_compaction_active: bool

Whether server-side compaction is currently active (skip client compaction when true, unless context has grown past the safety fallback threshold).

§token_counter: Arc<TokenCounter>

Token counter used for budget calculations and prompt recomputation.

§summarization_deps: SummarizationDeps

Pre-built summarization deps (provider + timeout + token_counter + callbacks). Built by the zeph-core shim from build_summarization_deps() before constructing the view, so the view does not need to hold a raw DebugDumper reference.

§task_supervisor: Arc<TaskSupervisor>

Background task supervisor for spawning non-blocking goal/subgoal extractions.

§memory: Option<Arc<SemanticMemory>>

Semantic memory store — used to flush deferred summaries and store session digests.

§conversation_id: Option<ConversationId>

Conversation ID for all SQLite/Qdrant persistence calls.

§tool_call_cutoff: usize

Maximum unsummarized tool-call pairs before forced deferred summarization kicks in.

§subgoal_registry: &'a mut SubgoalRegistry

In-memory registry of all subgoals in the current session.

§pending_task_goal: &'a mut Option<BlockingHandle<Option<String>>>

Handle to the background task-goal extraction spawned last turn.

§pending_subgoal: &'a mut Option<BlockingHandle<Option<SubgoalExtractionResult>>>

Handle to the background subgoal extraction spawned last turn.

§current_task_goal: &'a mut Option<String>

Cached task goal for TaskAware/MIG pruning. None before first extraction.

§task_goal_user_msg_hash: &'a mut Option<u64>

Hash of the last user message when current_task_goal was populated. Used to detect when a new extraction is needed.

§subgoal_user_msg_hash: &'a mut Option<u64>

Hash of the last user message when subgoal extraction was scheduled.

§status_tx: Option<UnboundedSender<String>>

TUI / channel status sender for spinner messages. None when TUI is disabled.

§scrub: fn(&str) -> Cow<'_, str>

Function pointer for scrubbing credentials from summary text.

Set to crate::redact::scrub_content by the zeph-core shim when redact_credentials = true, or to a no-op identity function otherwise.

§compression_guidelines: Option<String>

Compression guidelines text loaded from SQLite by the zeph-core shim.

None when the feature is disabled or the caller does not load guidelines. The service passes the contained string (or "") to summarize_with_llm. Closes #3528.

Set via ContextSummarizationView::with_compression_guidelines. Both the reactive (compact_context) and proactive (maybe_proactive_compress) paths populate this field.

§probe: Option<&'a mut dyn CompactionProbeCallback>

Optional probe-validation callback. When Some, the service invokes it after LLM summarization and before draining/reinsert. See CompactionProbeCallback for the full implementor contract.

§archive: Option<&'a dyn ToolOutputArchive>

Optional pre-summary archive hook (Memex #2432). The service calls archive(to_compact) BEFORE summarization and appends the returned reference list as a postfix AFTER the LLM call so the LLM cannot destroy the [archived:UUID] markers.

§persistence: Option<&'a dyn CompactionPersistence>

Optional persistence completion callback. The service calls after_compaction once the in-memory drain+reinsert is finalized. The optional Qdrant future returned by the callback is bubbled back through CompactionOutcome::Compacted::qdrant_future.

§metrics: Option<&'a dyn MetricsCallback>

Metrics sink for compaction-related counter increments. Used for compaction_hard_count, tool_output_prunes, and the four probe-outcome counters. Closes #3527.

§typed_pages: Option<Arc<TypedPagesState>>

Shared typed-page state for invariant-aware compaction (#3630).

None when [memory.compression.typed_pages] enabled = false. Populated by CompactionAdapters::populate in zeph-core.

Implementations§

Source§

impl ContextSummarizationView<'_>

Source

pub fn with_compression_guidelines(self, guidelines: Option<String>) -> Self

Set the compression guidelines text.

Call this on the view returned by Agent::summarization_view() before passing it to ContextService::compact_context. Using a builder method keeps construction uniform and avoids direct field mutation.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more