pub struct CompactionPolicy {
pub strategy: Arc<dyn CompactionStrategy>,
pub model_client: Arc<dyn ModelClient>,
pub context_window_tokens: u64,
}Expand description
Optional compaction wiring: strategy + the model client used to run
the summarize request + the resolved context-window cap. All three
must travel together; without any of them the loop can’t make a
useful compaction decision. AgentLoopHarness::with_compaction
installs it once and the per-turn loop checks it between steps.
Fields§
§strategy: Arc<dyn CompactionStrategy>§model_client: Arc<dyn ModelClient>Model client used by strategy.compact to run the summarize
request. Usually the same provider as the main turn model so the
Anthropic cache prefix stays hot; tests may swap in a fake.
context_window_tokens: u64Implementations§
Source§impl CompactionPolicy
impl CompactionPolicy
Sourcepub fn new(
strategy: Arc<dyn CompactionStrategy>,
model_client: Arc<dyn ModelClient>,
context_window_tokens: u64,
) -> Self
pub fn new( strategy: Arc<dyn CompactionStrategy>, model_client: Arc<dyn ModelClient>, context_window_tokens: u64, ) -> Self
Build a compaction policy from a custom strategy.
The strategy receives the full message history plus a
CompactionContext containing model_client, context_window_tokens,
and the current tool specs. Custom strategies may ignore the model
client entirely, or use it to produce their own summaries.
Sourcepub fn summarizing(
model_client: Arc<dyn ModelClient>,
context_window_tokens: u64,
) -> Self
pub fn summarizing( model_client: Arc<dyn ModelClient>, context_window_tokens: u64, ) -> Self
Build the default summarizing compaction policy used by the harness.
This preserves the existing compaction behavior: old oversized tool
outputs are pruned first, and when pruning is insufficient the history is
folded with SummarizeCompactionStrategy::default.
Trait Implementations§
Source§impl Clone for CompactionPolicy
impl Clone for CompactionPolicy
Source§fn clone(&self) -> CompactionPolicy
fn clone(&self) -> CompactionPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more