Skip to main content

dispatch_compaction

Function dispatch_compaction 

Source
pub fn dispatch_compaction(
    agents: Query<'_, '_, (Entity, &AgentState, &mut ContextWindow, &CompactionSettings), (With<ReadyToInfer>, Without<AwaitingCompaction>)>,
    stage: Res<'_, InferenceStage>,
    providers: Res<'_, Providers>,
    commands: Commands<'_, '_>,
)
Expand description

Compaction-dispatch system: for each ReadyToInfer agent with CompactionSettings whose window is over the eviction threshold, do the synchronous eviction inline; if that surfaces regions needing LLM summarization (and content to summarize), build one request per region, acquire a permit for the compaction model, spawn the job, and hold the agent as AwaitingCompaction. Anything that can’t proceed (under threshold, nothing to summarize, provider missing, pool full) simply leaves the agent ReadyToInfer so inference proceeds - compaction is best-effort. (Ported from AgentEngine::evict_and_compact.)