Skip to main content

ContextManager

Struct ContextManager 

Source
pub struct ContextManager { /* private fields */ }
Expand description

Context Management Infrastructure

Provides APIs for external orchestration layers to manage context windows.

Implementations§

Source§

impl ContextManager

Source

pub fn new(id: impl Into<String>) -> Self

Create a new context manager with default constraints

Source

pub fn with_constraints( id: impl Into<String>, constraints: ContextConstraints, ) -> Self

Create a context manager with custom constraints

Source

pub fn with_expansion_policy(self, policy: ExpansionPolicy) -> Self

Set the expansion policy

Source

pub fn with_pruning_policy(self, policy: PruningPolicy) -> Self

Set the pruning policy

Source

pub fn window(&self) -> &ContextWindow

Get a reference to the context window

Source

pub fn initialize_focus( &mut self, doc: &Document, focus_id: BlockId, task_description: &str, ) -> ContextUpdateResult

Initialize context with a focus block

Source

pub fn navigate_to( &mut self, doc: &Document, target_id: BlockId, task_description: &str, ) -> ContextUpdateResult

Navigate to a new focus area

Source

pub fn add_block( &mut self, doc: &Document, block_id: BlockId, reason: InclusionReason, ) -> ContextUpdateResult

Add a block to the context

Source

pub fn remove_block(&mut self, block_id: BlockId) -> ContextUpdateResult

Remove a block from the context

Source

pub fn expand_context( &mut self, doc: &Document, direction: ExpandDirection, depth: usize, ) -> ContextUpdateResult

Expand context in a direction

Source

pub fn compress( &mut self, doc: &Document, method: CompressionMethod, ) -> ContextUpdateResult

Compress blocks to fit within constraints

Source

pub fn get_statistics(&self) -> ContextStatistics

Get statistics about the context

Source

pub fn render_for_prompt(&self, doc: &Document) -> String

Render context to a format suitable for LLM prompts

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, 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> 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.