pub struct ContextConfig {
pub max_context_tokens: usize,
pub system_prompt_tokens: usize,
pub compaction: CompactionConfig,
pub token_counter: Option<Arc<dyn TokenCounter>>,
pub keep_recent: usize,
pub keep_first: usize,
pub tool_output_max_lines: usize,
}Expand description
Configuration for context management — model constraints + compaction policy.
CompactionConfig is a required field: if you set a context limit,
compaction is always ready with sensible defaults. Compaction as a whole
is disabled by setting context_config: None on AgentLoopConfig.
Fields§
§max_context_tokens: usizeMaximum context tokens (the model’s context window).
system_prompt_tokens: usizeTokens reserved for the system prompt.
compaction: CompactionConfigCompaction policy — always present when context limits are set.
token_counter: Option<Arc<dyn TokenCounter>>Custom token counter. When None, uses HeuristicTokenCounter (chars/4).
Set to a custom TokenCounter for model-specific tokenization.
keep_recent: usize§keep_first: usize§tool_output_max_lines: usizeImplementations§
Source§impl ContextConfig
impl ContextConfig
Sourcepub fn counter(&self) -> &dyn TokenCounter
pub fn counter(&self) -> &dyn TokenCounter
Returns the configured token counter, or the default heuristic (chars/4).
Trait Implementations§
Source§impl Clone for ContextConfig
impl Clone for ContextConfig
Source§fn clone(&self) -> ContextConfig
fn clone(&self) -> ContextConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ContextConfig
impl Debug for ContextConfig
Source§impl Default for ContextConfig
impl Default for ContextConfig
Source§impl<'de> Deserialize<'de> for ContextConfig
impl<'de> Deserialize<'de> for ContextConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for ContextConfig
impl !RefUnwindSafe for ContextConfig
impl Send for ContextConfig
impl Sync for ContextConfig
impl Unpin for ContextConfig
impl UnsafeUnpin for ContextConfig
impl !UnwindSafe for ContextConfig
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
Mutably borrows from an owned value. Read more