pub struct ContextManager { /* private fields */ }Expand description
Manager for handling context in a smart, efficient way
Implementations§
Source§impl ContextManager
impl ContextManager
Sourcepub fn with_tool_provider(self, provider: ToolProviderFn) -> Self
pub fn with_tool_provider(self, provider: ToolProviderFn) -> Self
Set a tool provider callback that supplies available tool name/summary pairs.
Sourcepub fn with_max_tokens(self, max_tokens: usize) -> Self
pub fn with_max_tokens(self, max_tokens: usize) -> Self
Set maximum context tokens
Sourcepub fn with_history_threshold(self, threshold: usize) -> Self
pub fn with_history_threshold(self, threshold: usize) -> Self
Set history summarization threshold
Sourcepub fn without_tool_schemas(self) -> Self
pub fn without_tool_schemas(self) -> Self
Disable tool schema inclusion for simpler contexts
Sourcepub fn analyze(&self, request: &str) -> RequestAnalysis
pub fn analyze(&self, request: &str) -> RequestAnalysis
Analyze a request to determine what context is needed
Sourcepub fn resolve_context<M>(
&self,
_request: &str,
analysis: &RequestAnalysis,
history: &[M],
workspace_dir: Option<&Path>,
) -> ResolvedContext
pub fn resolve_context<M>( &self, _request: &str, analysis: &RequestAnalysis, history: &[M], workspace_dir: Option<&Path>, ) -> ResolvedContext
Resolve context for a request
Sourcepub fn resolve_simple(
&self,
request: &str,
workspace_dir: Option<&Path>,
) -> ResolvedContext
pub fn resolve_simple( &self, request: &str, workspace_dir: Option<&Path>, ) -> ResolvedContext
Simple resolve without history
Sourcepub fn resolve_for_analysis_with_history<M>(
&self,
analysis: &RequestAnalysis,
history: &[M],
workspace_dir: Option<&Path>,
) -> ResolvedContext
pub fn resolve_for_analysis_with_history<M>( &self, analysis: &RequestAnalysis, history: &[M], workspace_dir: Option<&Path>, ) -> ResolvedContext
Resolve context for a pre-analyzed request with history
Sourcepub fn summarize_history<M>(&self, history: &[M]) -> String
pub fn summarize_history<M>(&self, history: &[M]) -> String
Summarize history with intelligent threshold (LOW-1)
Sourcepub fn resolve_for_analysis(
&self,
analysis: &RequestAnalysis,
workspace_dir: Option<&Path>,
) -> ResolvedContext
pub fn resolve_for_analysis( &self, analysis: &RequestAnalysis, workspace_dir: Option<&Path>, ) -> ResolvedContext
Resolve context for a pre-analyzed request (no history)
Sourcepub fn cache_stats(&self) -> ContextManagerStats
pub fn cache_stats(&self) -> ContextManagerStats
Get cache statistics
Sourcepub fn clear_caches(&self)
pub fn clear_caches(&self)
Clear all caches
Sourcepub fn compute_request_hash(&self, analysis: &RequestAnalysis) -> u64
pub fn compute_request_hash(&self, analysis: &RequestAnalysis) -> u64
Compute a hash for a request based on categories and key entities
Sourcepub fn get_cached_response(
&self,
analysis: &RequestAnalysis,
) -> Option<CachedResponse>
pub fn get_cached_response( &self, analysis: &RequestAnalysis, ) -> Option<CachedResponse>
Check if we have a cached response for a similar request
Sourcepub fn cache_response(&self, analysis: &RequestAnalysis, response: String)
pub fn cache_response(&self, analysis: &RequestAnalysis, response: String)
Cache a response for potential reuse
Sourcepub fn is_similar_to_recent(&self, analysis: &RequestAnalysis) -> bool
pub fn is_similar_to_recent(&self, analysis: &RequestAnalysis) -> bool
Check if a request is similar to a recent one (for deduplication)
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ContextManager
impl !RefUnwindSafe for ContextManager
impl Send for ContextManager
impl Sync for ContextManager
impl Unpin for ContextManager
impl !UnwindSafe for ContextManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].