Skip to main content

CompactionTrigger

Trait CompactionTrigger 

Source
pub trait CompactionTrigger: Send + Sync {
    // Required method
    fn should_compact(
        &self,
        session_id: &SessionId,
        turn_id: Option<&TurnId>,
        transcript: &[Item],
    ) -> Option<CompactionReason>;
}
Expand description

Decides whether compaction should run for a given transcript.

Implement this trait to create custom triggers. The built-in ItemCountTrigger fires when the transcript exceeds a fixed item count.

§Example

use agentkit_compaction::{CompactionReason, CompactionTrigger, ItemCountTrigger};
use agentkit_core::SessionId;

let trigger = ItemCountTrigger::new(32);
let items = Vec::new();
assert!(trigger.should_compact(&SessionId::new("s"), None, &items).is_none());

Required Methods§

Source

fn should_compact( &self, session_id: &SessionId, turn_id: Option<&TurnId>, transcript: &[Item], ) -> Option<CompactionReason>

Returns Some(reason) if compaction should run, None otherwise.

§Arguments
  • session_id - The current session identifier.
  • turn_id - The turn that is being evaluated, if any.
  • transcript - The full transcript to inspect.

Implementors§